RPG Maker
 

 Username:
 Password:
   Not a member? Register!

Home > RGSS Script Reference > Scene_Name

Scene_Name


Inherits from: None

Description: This class handles the "Enter Hero Name" screen.

Code


class Scene_Name
# ------------------------------------
 def main
    @actor = $game_actors[$game_temp.name_actor_id]
    @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char)
    @input_window = Window_NameInput.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @edit_window.dispose
    @input_window.dispose
  end
# ------------------------------------  
  def update
    @edit_window.update
    @input_window.update
    if Input.repeat?(Input::B)
      if @edit_window.index == 0
        return
      end
      $game_system.se_play($data_system.cancel_se)
      @edit_window.back
      return
    end
    if Input.trigger?(Input::C)
      if @input_window.character == nil
        if @edit_window.name == ""
          @edit_window.restore_default
          if @edit_window.name == ""
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          $game_system.se_play($data_system.decision_se)
          return
        end
        @actor.name = @edit_window.name
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
        return
      end
      if @edit_window.index == $game_temp.name_max_char
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if @input_window.character == ""
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @edit_window.add(@input_window.character)
      return
    end
  end
end

Properties


Actor: The actor whose name is being entered.

Edit_Window: A Window_NameEdit object that shows the name that's been entered so far.

Input_Window: A Window_NameInput object window that contains the name input window.

Methods


Main

Arguments: None
Local Variables: None

How it Works: This is the main method for this class. The first part of the method identifies the actor whose name is being changed and sets up the name edit and name entry windows. The next part of the method is the main loop seen in every "Scene" method. The graphics are updated, the engine checks for updated input, and the window contents are updated. This continues until the value of $Scene changes (in this case, because the user entered a name). Once this happens, the rest of the method disposes of the two window objects.

Update

Arguments: None
Local Variables: None

How it Works: This window updates the contents of the two windows and makes them respond to user input. First, the contents of the two windows are updated. Then, the current input is checked. If the user's input is "B" (cancel key), then it checks to see what the index of the edit window is (in this case, the index is the number of characters that have been entered). If the index is 0, the method does nothing and returns. If the index is 1 or more, then the cancel sound effect is played and the Window_NameEdit#Back method is called to backspace the name edit window one space. If the user's input is "C" (decision key), then it checks to see if the character selected in the name entry window is nil (the "done" option has this value). If the user hasn't entered a name at all, and a default name has been specified, then the default name is restored. If there is no default name, the buzzer sound effect is played. If the user has entered a name that is at least one character long, the actor's name is assigned the name entered in the name edit window and control is transferred back to the map. If the number of characters entered is equal to the maximum number of characters specified in the event command, the buzzer sound effect plays. Finally, if a valid character is selected, the Window_NameEdit#Add method is called to add that character to the name being constructed. 
Syntax
@
@@
$
alias
[array index]
attr_accessor
attr_reader
attr_writer
class
def
do
ensure
for
if
[iterator]
key => value
new
next
nil
redo
require
return
rescue
self
super
undef
unless
until
while
yield

Classes
Arrow_Actor
Arrow_Base
Arrow_Enemy
Game_Actor
Game_Actors
Game_BattleAct
Game_Battler
Game_Character
Game_Common
Game_Enemy
Game_Event
Game_Map
Game_Party
Game_Picture
Game_Player
Game_Screen
Game_SlfSwitch
Game_Switches
Game_System
Game_Troop
Game_Variables
Interpreter
Scene_Debug
Scene_End
Scene_Equip
Scene_File
Scene_Gameover
Scene_Item
Scene_Load
Scene_Map
Scene_Menu
Scene_Name
Scene_Save
Scene_Shop
Scene_Skill
Scene_Status
Scene_Title
Sprite_Battler
Sprite_Character
Sprite_Picture
Sprite_Timer
Spriteset_Battle
Spriteset_Map
Window_Base
Window_Battleresult
Window_Battlestatus
Window_Command
Window_DebugLeft
Window_DebugRight
Window_EquipItem
Window_EquipLeft
Window_EquipRight
Window_Gold
Window_Help
Window_InputNumb
Window_Item
Window_MenuStatus
Window_Message
Window_NameEdit
Window_NameInput
Window_PartyCom
Window_PlayTime
Window_SaveFile
Window_Selectable
Window_ShopBuy
Window_ShopCom
Window_ShopNum
Window_ShopSell
Window_ShopStatus
Window_Skill
Window_SkillStatus
Window_Status
Window_Steps
Window_Target

Other
Class Hierarchy
Global Variables


RPG RPG Revolution
RPG RPG Revolution is your #1 stop for game development and console RPG games, as well as those created by people like you. Link to us to support us, so we may grow to be better website community for you.

By continuing past this page, and by your continued use of this site, you agree to be bound by and abide by the Terms of Use.
©2004 - 2008 RPG RPG Revolution, All Rights Reserved. Contact Us · Privacy Policy · Legal Disclaimer
eXTReMe Tracker