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.

Tutorial script

elderm

Member

Hi,
I would like to make a ''Tutorial'' section, so when the player executes the game.exe, he will see a start title like this one:

START NEW GAME
CONTINUE
TUTORIAL
SHUT DOWN

And this tutorial I dont mean like text based, I mean it could be like game based. I hope you get what I mean. Sorry about my bad English.

Thanks
 
This ain't that hard, just copy and paste this into your Scene_Title.

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

MAPID = 1
X_Start = 2
Y_Start = 14

class Scene_Title
  #--------------------------------------------------------------------------
  # Defines the main processing of the Title Scene.
  #--------------------------------------------------------------------------
  def main
    # Checks if you're executing a Battle Test.
    if $BTEST
      battle_test
      return
    end
    # Load Data
    $data_actors        = load_data("Data/Actors.rxdata")
    $data_classes       = load_data("Data/Classes.rxdata")
    $data_skills        = load_data("Data/Skills.rxdata")
    $data_items         = load_data("Data/Items.rxdata")
    $data_weapons       = load_data("Data/Weapons.rxdata")
    $data_armors        = load_data("Data/Armors.rxdata")
    $data_enemies       = load_data("Data/Enemies.rxdata")
    $data_troops        = load_data("Data/Troops.rxdata")
    $data_states        = load_data("Data/States.rxdata")
    $data_animations    = load_data("Data/Animations.rxdata")
    $data_tilesets      = load_data("Data/Tilesets.rxdata")
    $data_common_events = load_data("Data/CommonEvents.rxdata")
    $data_system        = load_data("Data/System.rxdata")
    # Create
    $game_system = Game_System.new
    # Title Graphic
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
    # Commands
    s1 = "Start New Game"
    s2 = "Continue"
    s3 = "Tutorial"
    s4 = "Exit"
    @command_window = Window_Command.new(192, [s1, s2, s3, s4])
    @command_window.back_opacity = 160
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 288
    # Disables continue.
    @continue_enabled = false
    # Checks for savefiles.
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.sav")
        # If there's a savefile, there's a continue.
        @continue_enabled = true
      end
    end
    # Checks if continue is enabled, else disable the command.
    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(1)
    end
    # BGM play
    $game_system.bgm_play($data_system.title_bgm)
    # BGS & ME stop
    Audio.me_stop
    Audio.bgs_stop
    # Graphic
    Graphics.transition
    # Create Loop
    loop do
      # Graphics update
      Graphics.update
      # Key pressing update
      Input.update
      # update
      update
      if $scene != self
        # Break loop
        break
      end
    end
    # Graphics freeze
    Graphics.freeze
    # Disposing the command window.
    @command_window.dispose
    # Disposing the title graphic.
    @sprite.bitmap.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # Update the command window.
  #--------------------------------------------------------------------------
  def update
    # Command window update
    @command_window.update
    # Input update
    if Input.trigger?(Input::C)
      # Command window index
      case @command_window.index
      when 0
        command_new_game
      when 1
        command_continue
      when 2
        command_tutorial
      when 3
        command_shutdown
      end
    end
  end
  #--------------------------------------------------------------------------
  # This part defines the action that's executed when the player selects a new game.
  #--------------------------------------------------------------------------
  def command_new_game
    # SE play
    $game_system.se_play($data_system.decision_se)
    # BGM stop
    Audio.bgm_stop
    # Graphic
    Graphics.frame_count = 0
    # Create data
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    # Starting Party Members
    $game_party.setup_starting_members
    # Start Map ID
    $game_map.setup($data_system.start_map_id)
    # Teleport player to starting location
    $game_player.moveto($data_system.start_x, $data_system.start_y)
    # Player refresh
    $game_player.refresh
    # Map Audio play
    $game_map.autoplay
    # Update
    $game_map.update
    # New Scene
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # This part defines the action that's executed when the player selects continue.
  #--------------------------------------------------------------------------
  def command_continue
    # Checks if continue is disabled
    unless @continue_enabled
      # SE play
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    # SE play
    $game_system.se_play($data_system.decision_se)
    # New Scene
    $scene = Scene_Load.new
  end
  #--------------------------------------------------------------------------
  # This part defines the action that's executed when the player selects the tutorial.
  #--------------------------------------------------------------------------
  def command_tutorial
    # SE play
    $game_system.se_play($data_system.decision_se)
    # BGM stop
    Audio.bgm_stop
    # Graphic
    Graphics.frame_count = 0
    # Create data
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    # Starting Party Members
    $game_party.setup_starting_members
    # Start Map ID
    $game_map.setup($data_system.start_map_id = MAPID)
    # Teleport player to starting location
    $game_player.moveto($data_system.start_x = X_Start, $data_system.start_y = Y_Start)
    # Player refresh
    $game_player.refresh
    # Map Audio
    $game_map.autoplay
    # Map Update
    $game_map.update
    # New Scene
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # This part defines the action that's executed when the player selects shutdown.
  #--------------------------------------------------------------------------
  def command_shutdown
    # SE play
    $game_system.se_play($data_system.decision_se)
    # Audio fading
    Audio.bgm_fade(800)
    Audio.bgs_fade(800)
    Audio.me_fade(800)
    # New Scene
    $scene = nil
  end
  #--------------------------------------------------------------------------
  # This part will execute the Battle Test if you'll do a battle test from the database.
  #--------------------------------------------------------------------------
  def battle_test
    # Load Data
    $data_actors        = load_data("Data/BT_Actors.rxdata")
    $data_classes       = load_data("Data/BT_Classes.rxdata")
    $data_skills        = load_data("Data/BT_Skills.rxdata")
    $data_items         = load_data("Data/BT_Items.rxdata")
    $data_weapons       = load_data("Data/BT_Weapons.rxdata")
    $data_armors        = load_data("Data/BT_Armors.rxdata")
    $data_enemies       = load_data("Data/BT_Enemies.rxdata")
    $data_troops        = load_data("Data/BT_Troops.rxdata")
    $data_states        = load_data("Data/BT_States.rxdata")
    $data_animations    = load_data("Data/BT_Animations.rxdata")
    $data_tilesets      = load_data("Data/BT_Tilesets.rxdata")
    $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
    $data_system        = load_data("Data/BT_System.rxdata")
    # Graphic
    Graphics.frame_count = 0
    # Create data
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    # Setup
    $game_party.setup_battle_test_members
    # Get information.
    $game_temp.battle_troop_id = $data_system.test_troop_id
    $game_temp.battle_can_escape = true
    $game_map.battleback_name = $data_system.battleback_name
    # SE play
    $game_system.se_play($data_system.battle_start_se)
    # BGM play
    $game_system.bgm_play($game_system.battle_bgm)
    # New Scene
    $scene = Scene_Battle.new
  end
end

At the top of the script you'll see; MAPID, X_Start and Y_Start. Those represent the numbers of the tutorial's Map ID and the X and Y tile where the player starts.

You'll have to edit those numbers. Let's say your Tutorial Map's ID is 3, and you would like the player to spawn at 009x, 014y. Then the part at top of the script would look like :

MAPID = 3
X_Start = 9
Y_Start = 14

If you have any questions, feel free to ask.

I'm still learning ruby, don't expect this to be written in a 'pro' way.
 

elderm

Member

Thank you very much. I'll give it a try.

// It seemed to work, but it doesnt work with script NeoABS :(

Code:
Script '   o Player Progress' line 455: NoMethodError occured.

Undefined method 'dash_lenght' for nil:NilClass
 
I'll give this another attempt, I can't really test this cause my pc goes like spacecake if I testplay NeoABS. I think this should work (when using the script i gave you earlier), because it now actually loads NeoABS when pressing on the tutorial button :

Add this :

Code:
  alias mrmo_abs_scene_title_tpg command_tutorial
  #--------------------------------------------------------------------------
  # * Command: Tutorial
  #--------------------------------------------------------------------------
  def command_tutorial
    $NeoABS = UCoders::NeoABS.new    
    # Change Animation Size
    for an in $data_animations
      next if an.nil?
      frames = an.frames
      for i in 0...frames.size
        for j in 0...frames[i].cell_max
          frames[i].cell_data[j, 1] /= $NeoABS.animation_divide
          frames[i].cell_data[j, 2] /= $NeoABS.animation_divide
          frames[i].cell_data[j, 3] /= $NeoABS.animation_divide
        end
      end
    end
    mrmo_abs_scene_title_tpg
  end
end

after this in Class Additions :

Code:
  alias mrmo_abs_scene_title_cng command_new_game
  #--------------------------------------------------------------------------
  # * Command: New Game
  #--------------------------------------------------------------------------
  def command_new_game
    $NeoABS = UCoders::NeoABS.new    
    # Change Animation Size
    for an in $data_animations
      next if an.nil?
      frames = an.frames
      for i in 0...frames.size
        for j in 0...frames[i].cell_max
          frames[i].cell_data[j, 1] /= $NeoABS.animation_divide
          frames[i].cell_data[j, 2] /= $NeoABS.animation_divide
          frames[i].cell_data[j, 3] /= $NeoABS.animation_divide
        end
      end
    end
    mrmo_abs_scene_title_cng 
  end

In the Class Additions piece of code directly above this, I removed the last 'end'. You should do that too in your Class Additions from NeoABS else it will definitly give you an error.
 

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