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.

Gameplay hints after loading the game

Hello everyone.

I was wondering whether any of you knows what do I have to change if I want a random message from a predefined set displayed each time the game is loaded?

Furthermore, I would be reaaaly happy if after turning a particular switch ON the set of messages could be expanded (visiting a new place = possibility of showing also the hints concerning that particular place).

I'm just starting to learn Ruby, but I get it the above is pretty simple. Still, I cannot do it yet :| Please, could anyone help me in here?
 
Plz be more specific? If you need map & place info messages (showing the place etc) I have a custom menu script that is very (VERY) easy to customize of your own. But what do you need HELP with?
 
The thing that puzzles me the most is the timing- how to show a window with a message every time a Savegame is loaded? The message itself is just plain text like 'If you don't eat.....', which I'm going to prepare later


Still, I would be happy to see the script you've mentioned 9robin3, but the above script is more important :)
 
For clarification: I assume you mean a random advice string like the UT games or TF2 have...

The implementation of that isn't too much of a problem, all you have to do is get a window you want to display this in, then you can use this:
Code:
@advice_messages = ["BlueScope is awesome!", "The Interpreter is a spy!", "Draco is stealing BlueScope's lunch break."]

self.contents.draw_text(4, 0, self.width-40, self.height-40, @advice_messages[rand(@advice_messages.size)])
Pretty simple, but ask if you have any questions regarding that.

Now I don't know if you already have a loading screen, but either way, implementation is depending on how it's built. If you have a window in there already, just paste my code above in the refresh method, below self.contents.clean (without the array actually, which goes to initialize definition), and you should be fine (refer to the help file for positioning). If not, you want to create a window for it. Again, please ask if you need help with that. Ultimately, if you don't even have a loading screen... you're probably best off posting a thread in the Script Request forums then (though I'll give you some advice if you want to do it yourself).

Please give feedback if this helped ya.
 
DracoBlair":35xuoydd said:
The thing that puzzles me the most is the timing- how to show a window with a message every time a Savegame is loaded? The message itself is just plain text like 'If you don't eat.....', which I'm going to prepare later


Still, I would be happy to see the script you've mentioned 9robin3, but the above script is more important :)

Ok Draco here is the custom menu script. Maybe you can use it too:
Code:
#============================================================================

#L's Custom Menu - Simple DMS Edit 

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

 

module MenuCommand

  Item     = 'Item'

  Skill    = 'Magics'

  Equip    = 'Equip'

  Status   = 'Status'

  Save     = 'Save'

  Load     = 'Load'

  End_Game = 'Exit'

    

  Order    = 'Help'

  Party    = 'Party'

  Option   = ''

  Quest    = 'Quests'

  System   = 'Load/Save'

end

 

 

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

#  Game_Map

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

class Game_Map

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

#  Name

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

  def name

    $map_infos[@map_id]

  end

end

 

 

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

#â–  Scene_Title

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

# Setting functions for the Title

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

class Scene_Title

  $map_infos = load_data("Data/MapInfos.rxdata")

  for key in $map_infos.keys

    $map_infos[key] = $map_infos[key].name

  end

end

 

 

class Window_Infos < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(0, 0, 160, 130)

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

    refresh

  end

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

  # * Refresh

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

  def refresh

    self.contents.clear

    #---Show Time

    self.contents.font.color = system_color

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

    @total_sec = Graphics.frame_count / Graphics.frame_rate

    hour = @total_sec / 60 / 60

    min = @total_sec / 60 % 60

    sec = @total_sec % 60

    text = sprintf("%02d:%02d:%02d", hour, min, sec)

    self.contents.font.color = normal_color

    self.contents.draw_text(4, 0, 120, 32, text, 2)

    #---Show Money

    case $game_party.gold

      when 0..9999

        gold = $game_party.gold

      when 10000..99999

        gold = $game_party.gold.to_s

        array = gold.split(//)

        gold = array[0].to_s+array[1].to_s+""+array[2].to_s+array[3].to_s+array[4].to_s

      when 100000..999999 

        gold = $game_party.gold.to_s

        array = gold.split(//)

        gold = array[0].to_s+array[1].to_s+array[2].to_s+""+array[3].to_s+array[4].to_s+array[5].to_s

      when 1000000..9999999 

        gold = $game_party.gold.to_s

        array = gold.split(//)

        gold = array[0].to_s+""+array[1].to_s+array[2].to_s+array[3].to_s+""+array[4].to_s+array[5].to_s+array[6].to_s

    end

    

    self.contents.font.color = normal_color     

    cx = contents.text_size($data_system.words.gold).width    

    self.contents.draw_text(4, 67, 120-cx-2, 32, gold.to_s, 2)

    self.contents.font.color = system_color 

    self.contents.draw_text(124-cx, 67, cx, 32, $data_system.words.gold, 2)

  end

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

  # * Frame Update

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

  def update

    super

    if Graphics.frame_count / Graphics.frame_rate != @total_sec

      refresh

    end

  end

end

 

 

class Window_MapName < Window_Base

 def initialize

   super(0, 0, 160, 96)

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

   refresh

 end

 def refresh

   self.contents.clear

   self.contents.font.color = system_color

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

   self.contents.font.color = normal_color

   self.contents.draw_text(4, 32, 120, 32, $game_map.name.to_s, 2)

 end

end

 

 

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

# ** Scene_Menu

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

#  This class performs menu screen processing.

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

 

class Scene_Menu

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

  # * Object Initialization

  #     menu_index : command cursor's initial position

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

  def initialize(menu_index = 0)

    @menu_index = menu_index    

    commands_init

    @changer = 0 #Change Party Order by Yargovish

    @where = 0 #

    @checker = 0  #

  end

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

  # * Set Commands

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

  def commands_init

    @commands = []

    s1 = MenuCommand::Item

    s2 = MenuCommand::Skill

    s3 = MenuCommand::Equip

    s4 = MenuCommand::Status

    s5 = MenuCommand::System

    @commands.push(s1, s2, s3, s4, s5).flatten!

    

    

    @sys_commands = []

    o1 = MenuCommand::Save

    o2 = MenuCommand::Load

    o3 = MenuCommand::End_Game

    @sys_commands.push(o1, o2, o3).flatten!

  end

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

  # * Main Processing

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

  def main

    #Draw Windows    

    main_window

    #Execute transition

    Graphics.transition

    #Main Loop

    loop do

      #Main Loop

      main_loop

      break if main_scenechange?

    end

    #Prepare for transition

    Graphics.freeze

    #Dispose Windows

    main_dispose

  end

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

  # * Main Draw - Handles drawing windows

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

  def main_window

    #Draw Windows

    main_command_window

    system_command_window

    # Make Info Window

    @infos_window = Window_Infos.new

    @infos_window.x = 0

    @infos_window.y = 255

    # Make map name window

    @mapname_window = Window_MapName.new

    @mapname_window.x = 0

    @mapname_window.y = 384

    # Make status window

    @status_window = Window_MenuStatus.new

    @status_window.x = 160

    @status_window.y = 0     

    end

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

  # * Main Command Window

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

  def main_command_window 

    # Make command window    

    @command_window = Window_Command.new(160, @commands)

    @command_window.index = @menu_index

    if @command_window.height > 256

      @command_window.height = 256

    end

    # If number of party members is 0

    if $game_party.actors.size == 0

      # Disable items, skills, equipment, and status

      @command_window.disable_item(0)

      @command_window.disable_item(1)

      @command_window.disable_item(2)

      @command_window.disable_item(3)

    end

    if $game_party.actors.size <= 1 #

      #Disable change party order

      @command_window.disable_item(4)

    end

  end

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

  # * System Command Window

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

  def system_command_window    

    @sys_command_window = Window_Command.new(128, @sys_commands)

    @sys_command_window.visible = false

    @sys_command_window.active = false

    @sys_command_window.x = 100

    @sys_command_window.y = 210

    @sys_command_window.z = 0

    check_save_available

    check_load_available

  end

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

  def check_save_available

    # If save is forbidden

    if $game_system.save_disabled

      # Disable save

      @sys_command_window.disable_item(1)

    end

  end

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

  def check_load_available

    #Check if saved file exists

    @load_enabled = false

    for i in 0..3

      if (FileTest.exist?("Save#{i+1}.rxdata"))        

        @load_enabled = true

      end

    end  

    if !@load_enabled

      #Put your @command_window.disable_item(index)

      @sys_command_window.disable_item(2)

    end

  end

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

  # * Main Scene Change 

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

  def main_scenechange?

    # Abort loop if screen is changed

    if $scene != self

      return true

    end

    return false

  end

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

  # * Main Dispose 

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

  def main_dispose

    # Dispose All Windows

    @command_window.dispose

    @sys_command_window.dispose

    @infos_window.dispose

    @mapname_window.dispose

    @status_window.dispose

  end

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

  # * Main Loop 

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

  def main_loop

    # Update game screen

    Graphics.update

    # Update input information

    Input.update

    # Frame update

    update

  end

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

  # * Frame Update

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

  def update

    # Update Windows

    update_windows

    

    if @sys_command_window.active

      @sys_command_window.z = +500

    end

    

    # If command window is active: call update_command

    if @command_window.active

      update_command

      return

    end

    # If system window is active: call update_sys_command

    if @sys_command_window.active

      update_sys_command

      return

    end

    # If status window is active: call update_status

    if @status_window.active

      update_status

      return

    end

  end

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

  # * Window Update 

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

  def update_windows    

    @command_window.update if @command_window.visible

    @sys_command_window.update if @sys_command_window.visible

    @infos_window.update

    @status_window.update

    @mapname_window.update

  end

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

  # * Frame Update (when command window is active)

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

  def update_command

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to map screen

      $scene = Scene_Map.new

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Return if Disabled Command

      if disabled_main_command?

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      main_command_input

      return

    end

  end

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

  # * Update SysCommand Window

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

  def update_sys_command

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @command_window.active = true

      @sys_command_window.active = false

      @sys_command_window.visible = false

      @sys_command_window.index = 0

      @sys_command_window.z = -500

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Return if Disabled Command

      if disabled_main_command?

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      # Command Input

      sys_command_input

      return

    end

  end

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

  # * Frame Update (when status window is active)

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

  def update_status

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Make command window active

      @command_window.active = true

      @status_window.active = false

      @status_window.index = -1

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Return if Disabled Command

      if disabled_main_command?

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      # Command Input

      sub_command_input

      return

    end

  end

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

  # * Disabled Main Command? Test

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

  def disabled_main_command?

    # Gets Current Command

    command = @commands[@command_window.index]

    sys_command = @sys_commands[@sys_command_window.index]

    # Gets Menu Commands

    c = MenuCommand

    # If 0 Party Size

    if $game_party.actors.size == 0

      # If Item, Skill, Equip or Status Selected

      if [c::Item, c::Skill, c::Equip, c::Status].include?(command)

        return true

      end

    end

    if $game_party.actors.size <= 1

      if [c::Order].include?(command)

        return true

      end

    end

    # If Save Disabled && Command is Save

    return true if $game_system.save_disabled && sys_command == c::Save

    # If Load Disabled && Command is Load

    return true if !@load_enabled && sys_command == c::Load

    return false

  end

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

  # * Update Command Check

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

  def main_command_input

    # Loads Current Command

    command = @commands[@command_window.index]

    # Play decision SE

    $game_system.se_play($data_system.decision_se)

    # Checks Commands

    case command

    when MenuCommand::Item  #item

      command_item

    when MenuCommand::Skill #skill

      command_skill

    when MenuCommand::Equip #equip

      command_equip

    when MenuCommand::Status  #status

      command_status

    when MenuCommand::Order #help

      command_order

    when MenuCommand::System  #call system submenu

      $game_system.se_play($data_system.decision_se)

      @sys_command_window.active = true

      @sys_command_window.visible = true

      @command_window.active = false     

    end

  end

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

  # * Update System Command Check

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

  def sys_command_input

    # Loads Current Command

    sys_command = @sys_commands[@sys_command_window.index]

    # Play decision SE

    $game_system.se_play($data_system.decision_se)

    # Checks Commands

    case sys_command

    when MenuCommand::Option  #option

      command_option

    when MenuCommand::Save  #save

      command_save

    when MenuCommand::Load  #load

      command_load

    when MenuCommand::End_Game  #exit

      command_endgame

    end

  end

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

  # * Disabled Sub Command? Test

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

  def disabled_sub_command?

    # Loads Current Command

    command = @commands[@command_window.index]

    # If Skill Selected

    if command == MenuCommand::Skill

      # If this actor's action limit is 2 or more

      if $game_party.actors[@status_window.index].restriction >= 2

        return true

      end

    end

    return false

  end

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

  # * Update Status Check

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

  def sub_command_input

    # Loads Current Command

    command = @commands[@command_window.index]

    # Play decision SE

    $game_system.se_play($data_system.decision_se)

    # Checks Command By Name

    case command

    when MenuCommand::Skill

      command_skill

    when MenuCommand::Equip

      command_equip

    when MenuCommand::Status

      command_status

    when MenuCommand::Order

      command_order

    end

  end

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

  # * Command Item

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

  def command_item

    # Switch to item screen

    $scene = Scene_Item.new

  end

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

  # * Command Skill

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

  def command_skill

    # If Main Command Active

    if @command_window.active

      # Activate Status Window

      active_status_window

      return

    end

    # Switch to skill screen

    $scene = Scene_Skill.new(@status_window.index)

  end

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

  # * Command Equip

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

  def command_equip

    # If Main Command Active

    if @command_window.active

      # Activate Status Window

      active_status_window

      return

    end

    # Switch to equipment screen

    $scene = Scene_Equip.new(@status_window.index)

  end

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

  # * Command Status

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

  def command_status

    # If Main Command Active

    if @command_window.active

      # Activate Status Window

      active_status_window

      return

    end

    # Switch to status screen

    $scene = Scene_Status.new(@status_window.index)

  end

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

  # * Command Help

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

  def command_help

    # If Main Command Active

    if @command_window.active

      # Activate Status Window

      active_status_window

      @checker = 0

      return

    end

    #Change Party Order by Yargovish

    if @checker == 0

      @changer = $game_party.actors[@status_window.index]

      @where = @status_window.index

      @checker = 1

    else

      $game_party.actors[@where] = $game_party.actors[@status_window.index]

      $game_party.actors[@status_window.index] = @changer

      @checker = 0

      @status_window.refresh

      $game_player.refresh #

    end      

  end

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

  # * Command Party

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

  def command_party

    # Switch to party change screen

    #Put your Party Change Scene here

  end

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

  # * Command Option

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

  def command_option

    # Switch to party change screen

    #Put your Option Scene here

  end

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

  # * Command Quest

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

  def command_quest

    # Switch to party change screen

      @command_window.active = false

      @status_window.active = true

  end

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

  # * Command Save

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

  def command_save

    # Switch to save screen

    $scene = Scene_Save.new

  end

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

  # * Command Load

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

  def command_load

    # Switch to load screen

    $scene = Scene_Load.new

  end

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

  # * Command End Game

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

  def command_endgame

    # Switch to end game screen

    $scene = Scene_End.new

  end

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

  # * Activate Status Window

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

  def active_status_window

    # Make status window active

    @command_window.active = false

    @status_window.active = true

    #@status_window.visible = true 

    @status_window.index = 0

  end

end

 

 

It is very easy to change.

You can ADD THIS to th "Main Command Window" Part in the script:

@command_window.x = <your value here>
@command_window.y = <your value here>


By adding this and write other numbers in x,y value, you will be able to move the main command window (the window with
items,magics,status etc.)


/Hope I was to any help! ~9robin3
 
Thanks very much :). I'm learning more and more thanks to both the Menu Script and the code from BlueScope. I'm a newbie in RGSS anyway and at the moment I've got a problem with displaying text in my window. Here's the code of the window:

Code:
class TIPWindow < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(150, 100, 350, 250)

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

   # Calls the refresh function in this class

    refresh 

      end

 

  def refresh

   self.contents.clear   

   self.contents.draw_text(4, 0, self.width-3, self.height-3,"Hey, mon!")

   self.contents.font.color = normal_color

   self.contents.font.size = 20

      end

  

end

And here is my scene (activated by $Scene_Load 52 $scene = Scene_ShowWindow.new

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

# * Scene_ShowWindow - polaczenie z Window_TIP

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

 

class Scene_ShowWindow

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

  # * Main Processing

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

  def main

    #call the window

    @window = TIPWindow.new

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

     end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of windows

    @window.dispose

  end

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

  # * Frame Update

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

    def update

    # Update windows

    @window.update

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to Menu screen

      $scene = Scene_Map.new

      return

    end

  end

end

 

The result is a blank window, not very useful I'm affraid :|

///EDIT: Yay, found the culprit ;D Now I'll try inserting the method :) (To confuse Refresh and Initialise..... ehhhhhhhhh ;D )
 
self.contents.font.color = normal_color and self.contents.font.size = 20 should be declared before self.contents.draw_text if there's just a single string to be displayed / printed on screen...

(BTW, there's no need to use self.contents.font.color = normal_color at all because that's the default color, so that line is redundant in this case.)
 
DracoBlair":3szh9slg said:
Thanks very much :). I'm learning more and more thanks to both the Menu Script and the code from BlueScope. I'm a newbie in RGSS anyway and at the moment I've got a problem with displaying text in my window. Here's the code of the window:

Code:
class TIPWindow < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(150, 100, 350, 250)

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

   # Calls the refresh function in this class

    refresh 

      end

 

  def refresh

   self.contents.clear   

   self.contents.draw_text(4, 0, self.width-3, self.height-3,"Hey, mon!")

   self.contents.font.color = normal_color

   self.contents.font.size = 20

      end

  

end

And here is my scene (activated by $Scene_Load 52 $scene = Scene_ShowWindow.new

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

# * Scene_ShowWindow - polaczenie z Window_TIP

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

 

class Scene_ShowWindow

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

  # * Main Processing

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

  def main

    #call the window

    @window = TIPWindow.new

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

     end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of windows

    @window.dispose

  end

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

  # * Frame Update

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

    def update

    # Update windows

    @window.update

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to Menu screen

      $scene = Scene_Map.new

      return

    end

  end

end

 

The result is a blank window, not very useful I'm affraid :|

///EDIT: Yay, found the culprit ;D Now I'll try inserting the method :) (To confuse Refresh and Initialise..... ehhhhhhhhh ;D )


Cool Draco ;) Very good so you seem to have learned a little bit about scripting!
 

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