Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Menu command launches different Scene depending on actor selected, (Couldn't think of a more straightforward name)
richardpilbeam
post Apr 23 2012, 05:08 AM
Post #1


Level 1
Group Icon

Group: Member
Posts: 14
Type: None
RM Skill: Intermediate




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.
Go to the top of the page
 
+Quote Post
   
Moonpearl
post Apr 23 2012, 05:22 AM
Post #2


Level 5
Group Icon

Group: Member
Posts: 73
Type: Developer
RM Skill: Advanced




Looks good, but you need to remove the @ before actor. Only classes use it to refer to their own instance variables.


__________________________





Go to the top of the page
 
+Quote Post
   
richardpilbeam
post Apr 23 2012, 06:56 PM
Post #3


Level 1
Group Icon

Group: Member
Posts: 14
Type: None
RM Skill: Intermediate




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>


This post has been edited by richardpilbeam: Apr 23 2012, 07:48 PM
Go to the top of the page
 
+Quote Post
   
Moonpearl
post Apr 23 2012, 08:56 PM
Post #4


Level 5
Group Icon

Group: Member
Posts: 73
Type: Developer
RM Skill: Advanced




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.


__________________________





Go to the top of the page
 
+Quote Post
   
richardpilbeam
post Apr 23 2012, 10:04 PM
Post #5


Level 1
Group Icon

Group: Member
Posts: 14
Type: None
RM Skill: Intermediate




So what should I change to make it function properly?
Go to the top of the page
 
+Quote Post
   
brewmeister
post Apr 24 2012, 02:54 AM
Post #6


Paste above Main
Group Icon

Group: Revolutionary
Posts: 408
Type: Scripter
RM Skill: Skilled




try

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


__________________________
Go to the top of the page
 
+Quote Post
   
richardpilbeam
post Apr 24 2012, 03:17 AM
Post #7


Level 1
Group Icon

Group: Member
Posts: 14
Type: None
RM Skill: Intermediate




Works fine, thanks!
Go to the top of the page
 
+Quote Post
   
jewel86
post May 10 2012, 08:43 PM
Post #8



Group Icon

Group: Member
Posts: 1
Type: None
RM Skill: Undisclosed




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


__________________________
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 11:08 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker