Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Better Inventory / HUD / Keyboard Shortcuts

Near's Inventory/HUD/Shortcut Script Version 1.0
By: Near

Introduction

This script (or script compilation) creates a small HUD on
the map/menu, an inventory grid, and allows the player to set
shortcuts for certain scenes. This script is simply plug 'n' play.

Features

  • Nice little HUD
  • Sweet Grid Inventory
  • Keyboard Shortcuts

Screenshots

scr004el1.png

scr003lw2.png

scr002da3.png

scr001jz9.png


Demo

http://www.mediafire.com/?sharekey=7e28669a9545db99d2db6fb9a8902bda


Instructions

This script is just plug 'n' play basically.
To open the Shortcuts menu press Ctrl + Q or W

FAQ

No questions yet.

Compatibility

Will not work with any CMSes(that I know of) and will not work
with Large Party scripts.

Author's Notes

Just ignore the RPG::Item script. I am working on item weights for the inventory system.

Terms and Conditions

Credit is necessary, and don't claim as your own.
 
Some suggestions from Seph

1) I don't suggest adding \w[n] to the description for weight. For one, you are having to call the set_weight method, which ends up just adding a bunch of new lines of code to go through.

Why not try this:
Code:
class RPG::Item

  # weapon_id => weight

  Weight = {}

  # default weight

  Weight.default = 1

  def weight

    return Weight[@id]

  end

end

Cuts your 93 lines down pretty quickly. Not as simple as adding the \w in the item description, but a little more efficient.

------------------------------------------------------

2) This code:
Code:
    draw_actor_graphic(@actor1, 64, y1)

    draw_actor_graphic(@actor2, 164, y1)

    draw_actor_graphic(@actor3, 264, y1)

    draw_actor_graphic(@actor4, 364, y1)

    draw_actor_name(@actor1, 32, y2)

    draw_actor_name(@actor2, 140, y2)

    draw_actor_name(@actor3, 240, y2)

    draw_actor_name(@actor4, 340, y2)

    self.contents.draw_text(420, 23, 64, 32, $data_system.words.gold)

    self.contents.draw_text(440, 46, 144, 32, $game_party.gold.to_s)

  end

  def reset_actors

    @actor1 = $game_party.actors[0]

    @actor2 = $game_party.actors[1]

    @actor3 = $game_party.actors[2]

    @actor4 = $game_party.actors[3]

 

What happens if there is only 1, 2 or 3 actors in the party?

I also suggest a loop function. Could cut down on some lines:
Code:
class Window_Hud < Window_Base

  def initialize

    super 0, 320, 640, 160

    self.contents = Bitmap.new(width - 32, height - 32)

    self.z = 1

    self.opacity = 160

    self.back_opacity = 120

    refresh

  end

  def refresh

    self.contents.clear

    @actors = $game_party.actors

    y1, y2 = 64, 75

    for i in [email=0...@actors.size]0...@actors.size[/email]

      draw_actor_name(@actors[i], 32 + i * 100, y2)

      draw_actor_graphic(@actors[i], 64 + i * 100, y1)

    end

    self.contents.draw_text(420, 23, 64, 32, $data_system.words.gold)

    self.contents.draw_text(440, 46, 144, 32, $game_party.gold.to_s)

  end

end

------------------------------------------------------

3) This block right here:
Code:
      case @cwin.index

      when 0

        $shortcuts[@key] = Scene_Item.new

      when 1

        $shortcuts[@key] = Scene_Status.new

      when 2

        $shortcuts[@key] = Scene_Equip.new

      when 3

        $shortcuts[@key] = Scene_Skill.new

      when 4

        $shortcuts[@key] = Scene_Save.new

      end

You are essentially making new objects and saving them to the $shortcuts variable. I suggest instead setting class name (remove the .new) Then down on your $scene = $shortcuts[0] line, change those to $scene = $shortcuts[0].new. Create the new object then.

I would also suggest adding this little method in Window_Command
Code:
class Window_Command

  def command(index = self.index)

    return @commands[index]

  end

end

The reason for this is because I have found it better practice to not base command windows based off indexes, but the command itself. This way, you can add other commands without having to change all the index values in your case. So you would have

case @cwin.command

In the end, this makes things easier in the future.

------------------------------------------------------

The only other thing would be to modify Window_Item to not spread the icons by 28, but by the default of 32. This is more a general practice. You could then remove those methods below update_help, that modify the cursor height to 28.

------------------------------------------------------

Finally, I suggest adding a specialized update method in Window_HUD. The purpose of this is to check if the actors change. Just create some some flag variables that hold @character_name, @character_hue and @name of your actors in the refresh method. Then in the update method, compare party size and those instances.

Code:
def refresh

  @actors = $game_party.actors

  @size = @actors.size

  @character_names = @actors.collect {|n| n.character_name}

  @character_hues = @actors.collect {|n| n.character_hue}

  @names = @actors.collect {|n| n.name}

  # ...

 

  def update

    super

    character_names = $game_party.actors.collect {|n| n.character_name}

    character_hues = $game_party.actors.collect {|n| n.character_hue}

    names = $game_party.actors.collect {|n| n.name}

    if @size != @actors.size || character_names != @character_names ||

       character_hues != @character_hues || names != @names

      refresh

    end

Something like that. The same thing is done in Sprite_Character/Sprite_Battler in the update methods if you would like to see another example of this.

------------------------------------------------------

Pretty good script. I like the idea for the shortcuts and the Window_Item modification looks much better than the default one. I don't mean to pick apart your script, just offer guidance, as I see potential in you. :thumb:
 
Thanks, I knew that it wasn't the cleanest code when I posted it, but I wanted to make a public release before I modified it anymore (helps in case I screw my file up, I have a demo download).

Also, I did the \w[n] thing for sheer simplicity, because I always hate having to look through every weapon id in my database and try to remember 4 or 5 at a time. And I am not using that script yet anyway. I wanted to make sure it worked, and I was think maybe I should make the Inventory more like 'Golden Sun', where each party member has his/her own inventory and party members can trade and give items to each other.

And thanks for the info on the HUD, I had no idea the '.collect' method even existed. (And I have read the help file. Many times) And you're right, the HUD probably would have crashed if you had less people in your party.

And one more thing, the Keyboard Shortcuts were my favorite to do, because it made the system so much easier to access. But I did not
know wether or not I could use classes without calling their 'new' method.
like: $dummy = Scene_Item ; I always thought you had to initialize the
object before you could save it into a variable.

And one more thing (for real this time) I really appreciate your help man, I
am still working on the coding side of RMXP, and I have been struggling
with some things. Like for instance, the Platformer Game... I did it perfectly
with events and one new script method, and I tried it fully scripted, and
my guy jumped through the roof and never came back down. Also, I did a
perfect ABS with events, and I've always wanted to code one, but never knew where to start. So really, thanks for the help with not only this script, but also my Mouse Module, and all my random scripting questions.
 
.collect actually isn't even included in most Array documentation (why .collect! is and not .collect is beyond me). But you can see documentation on .collect in the Enumerable module.

Well Scene_Item can be assigned, as it is actually a constant. Ruby is just cool that way. lol

And no problem. I'd be happy to help you with anything you need. :thumb:
 
Thanks, and also, I haven't gotten a chance yet to see what happens when you have less than 4 actors in your party, I'm at school. Wouldn't it raise a NoMethodError ? undefined method 'character_name' for nil:NilClass or something of the like?

And a bit of random off topic-ness: Didn't you create a script at one point, that made scripted event creation easier? I might be able to use that.
 
Shweet. I was gonna do something like that at one point... and then I gave up because I kept getting an Uninitialized Constant Error.

But one question that I have been wondering about. Can have an instance variable in a module that is a class?

Like:
module Near
  @class = NearClass.new
end

I tried that with a module I was making to go with another script,
but I got several errors.
 
Wow, the download doesn't work... so you necropost instead of PMing me? :haha:

Honestly, this garbage isn't worth downloading, it's unstable and I'm not developing it any further. So, if you still want it that bad, PM me and I'll send it, but it's your job to figure out how to get it working :biggrin:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top