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.

Window_Tip

Here is an idea I had, and was wondering if it was scriptable. Basiclly, this window would be a window that displays like a sentence of text depending on the value of a certain variable, to give a tip to the player of where to go next. I would need it to be a window of a size of 320x64.

I don't know much about scripting, but I would like it if it were in a format similar to this

[1] = "Go to the house"
[2] = "Go to the market"

e.t.c.

Where the number is the value of whatever the variable is.
 
That would be easier. Untested Code: The Default variable it's based on is one. When you want to change it just change the variable. I'll make it so It'll update soon.
Code:
#===============================================================================
# ** Class Game_Tip
#-------------------------------------------------------------------------------
#   * Runs processing on all tips for the player to read
#===============================================================================
class Game_Tip
  attr_accessor :text
  attr_accessor :variablenumber
  def initialize
    @text = Hash.new(0)       #set text as Hash. Change Zero to Default Tip
    @text[0] = "Text"         #Text of Tip given when Variable is set to 2
    @text[1] = "Text2"        #Text of Tip given when Variable is set to 1
    @variablenumber = 0       #number of variable text is based after
  end
end
#===============================================================================
# ** Class Window_Tip
#-------------------------------------------------------------------------------
#   * Runs processing on Scene Map's Window_Tip
#===============================================================================
class Window_Tip < Window_Base
  def initialize
    super(0,0,320,64)
    $game_tip = Game_Tip.new
    self.contents = Bitmap.new
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.draw_text(0, 0, 320, 64, $game_tip.text[$game_variables[$game_tip.variablenumber]).to_s
  end
end
#===============================================================================
# ** Class Scene_Map
#-------------------------------------------------------------------------------
#   * Edits processing on the Scene Map Class
#===============================================================================
class Scene_Map
  alias maindraws89 main
  alias mainupdates89 update
  def main
    @tipwindow = Window_Tip.new
    maindraws89
    @tipwindow.dispose
  end
  def update
    @tipwindow.update
    mainupdates89
  end
end
 
It's supposed to be:

Code:
self.contents.draw_text(0, 0, 320, 64, $game_tip.text[$game_variables[$game_tip.variablenumber]].to_s)

...and I still don't see why you don't just use Window_Help. :p
 
I really don't know how to :(

And now I'm getting an erorr for line 25

Code:
class Window_Tip < Window_Base
  def initialize
    super(0,0,320,64)
    $game_tip = Game_Tip.new
    [b]self.contents = Bitmap.new[/b]
    refresh
 
Code:
#===============================================================================
# ** Class Game_Tip
#-------------------------------------------------------------------------------
#   * Runs processing on all tips for the player to read
#===============================================================================
class Game_Tip
  attr_accessor :text
  attr_accessor :variablenumber
  def initialize
    @text = Hash.new(0)       #set text as Hash. Change Zero to Default Tip
    @text[0] = "Text"         #Text of Tip given when Variable is set to 2
    @text[1] = "Text2"        #Text of Tip given when Variable is set to 1
    @variablenumber = 0       #number of variable text is based after
  end
end
#===============================================================================
# ** Class Window_Tip
#-------------------------------------------------------------------------------
#   * Runs processing on Scene Map's Window_Tip
#===============================================================================
class Window_Tip < Window_Base
  def initialize
    super(0,0,320,64)
    $game_tip = Game_Tip.new
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.draw_text(0, 0, 320, 32, $game_tip.text[$game_variables[$game_tip.variablenumber]].to_s)
  end
end
#===============================================================================
# ** Class Scene_Map
#-------------------------------------------------------------------------------
#   * Edits processing on the Scene Map Class
#===============================================================================
class Scene_Map
  attr_accessor :tipwindow
  alias maindraws89 main
  alias mainupdates89 update
  def main
    @tipwindow = Window_Tip.new
    maindraws89
    @tipwindow.dispose
  end
  def update
    @tipwindow.update
    mainupdates89
  end
end

Tested Code ^^
It works now. Just replace it. And now you can add $scene.tipwindow.refresh in a script call event after you change the variable to update the window to cause zero lag.
 

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