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.

Using an in game variable in a script?

Code:
#==============================================================================

# ** Window_Steps

#------------------------------------------------------------------------------

#  This window displays your steps on the menu screen.

#==============================================================================

 

class Window_Steps < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(0, 0, 160, 96)

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

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    self.contents.font.color = system_color

    self.contents.draw_text(4, 0, 120, 32, "Honor")

    self.contents.font.color = normal_color

    self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2)

  end

end

 


That script is the step window's code. I want to replace the steps taken with my variable that represents the main actor's Honor points. In my case, the variable is variable 3. How would I go about doing this?
 
You can reference to these variables by using $game_variables[n], where n is any number between 1 and whatever your highest variable number is. Remember not to put leading zeroes in there.
The part in the script you actually have to replace with that is $game_party.steps (keep the .to_s

Also, this is a topic that should be in every scripting FAQ on this planet... you're better off trying to go through some tutorials first if you start scripting rather than trial and error, then come crying for help ^^ (trial and error works great, as long as you keep trying!)
 

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