Help - Search - Members - Calendar
Full Version: Menu command launches different Scene depending on actor selected
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
richardpilbeam
So this is theoretically simple, but I can't get it working with my nonexistent understanding of Ruby.

The idea here is that each character has a unique non-combat skill system, which have their own separate scripts. So we've got Scene_Craft, Scene_Alchemy, Scene_Enchant etc., each with an associated character.

Rather than have each one be a separate menu command, I want it set up like the "Skill" / "Equip" / "Status" commands, where you select one command from the menu and are then prompted to select a member of the party to retrieve the data from. However, instead of retrieving data, I want it to check the character's ID and then launch the associated Scene. I've got it to activate the status window, but I can't get it to do the "if it's on character 01, launch scene 01" thing without giving me syntax errors.

If it's any help figuring out what I'm attempting, the current state of my code before I gave up is:

CODE
      when 4  # Crafting
      if $game_party.actors[@status_window.index].@actor.id == 1
           $scene = Scene_Crafting
          return
          end
      if $game_party.actors[@status_window.index].@actor.id == 2
           $scene = Scene_Alchemy
          return
          end


So you can vaguely see what I'm trying to do, even though it's obviously not working.

Thanks to anyone who can sort me out.
Moonpearl
Looks good, but you need to remove the @ before actor. Only classes use it to refer to their own instance variables.
richardpilbeam
Still says actor is an undefined method.

The exact code I'm using to test, added to Scene_Menu, is:

CODE
      when 4  # crafting
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0


And then later on in Scene_Menu:

CODE
      when 4  # crafting
        if $game_party.actors[@status_window.index].actor.id == 1
          $scene = Scene_Mechanic.new
          return
        end
        
        if $game_party.actors[@status_window.index].actor.id == 2
          $scene = Scene_Alchemy.new
          return
        end


The error message is:

QUOTE
Script 'Scene_Menu' line 220: NoMethodError occurred.

undefined method 'actor' for #<Game_Actor:0x1516f78>
Moonpearl
Of course, I didn't see this the ast time, but the Game_Party#actors array contains actors. So if you're further asking for the actor's actor, the interpreter is completely lost.
richardpilbeam
So what should I change to make it function properly?
brewmeister
try

if $game_party.actors[@status_window.index].id == 1
richardpilbeam
Works fine, thanks!
jewel86
QUOTE (brewmeister @ Apr 24 2012, 03:54 AM) *
try

if $game_party.actors[@status_window.index].id == 1


i'm newbie. Thanks your sharing. Hope to recive your helping from u biggrin.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.