Jump to content
New account registrations are disabed. This website is now an archive. Read more here.

lupin

Member
  • Content Count

    1
  • Joined

  • Last visited

Everything posted by lupin

  1. lupin

    Switch Scripting

    After a day and such of intense searching and looking at examples, I FINALLY figured how to do the very simple thing I wanted to do. Namely, check to see if a character has a piece of equipment currently equipped and activate/deactivate a switch accordingly. HOWEVER, it only works if the player equips the armor, exits the menu then reenters the menu, then the switch will activate. This also works if you enter than exit a building. As you may have guessed, I've inserterted the Script to run before any dialogue happens between player and NPC. In order: Equip item. Talk to NPC. -> NPC behaves as if you haven't changed equipment, if you talk to him 100 times in a row, it doesn't change anything. Open up menu. Close menu. It's obvious the switch has activated because the movement pattern is now different. NPC behaves as if you're wearing the item, the switch is on. Unequip. Talk to NPC -> He behaves as if you're still wearing the item Open menu. Close menu. Switch is now off, movement is different and NPC behaves as if the item is unequipped. I don't know how, via script to "instantly" enable a switch. Here's the code I have so far that's located above main and below materials. #============================================================================== # ** Game_Actor #------------------------------------------------------------------------------ # This class handles actors. It's used within the Game_Actors class # ($game_actors) and referenced by the Game_Party class ($game_party). #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :armor3_id # Body Armor Slot end def armor3_id # Very simple method that returns the armor currently being worn in slot 3. return $data_armors[@armor3_id] end #============================================================================== # ** Game_Switches #------------------------------------------------------------------------------ # This class handles switches. It's a wrapper for the built-in class "Array." # The instance of this class is referenced by $game_switches. #============================================================================== class Game_Switches #attr_accessor :id #currently commented out because this apparently has nothing to do with anything, seems to behave the same without it end def apples (switch, value) # I pass apples the switch I want to activate, and the state I would like to set it to (true/false). if switch <= 5000 # Also, named apples because I felt like it. I know that's totally against programming practice, but I don't care : ) $game_switches[switch] = value #According to the header $game_switches contains important stuff relevant to the method end end The actual code I have in the "Script..." area that's executing is... if $game_actors[1].armor3_id == 2 #If actor 1 is wearing item 2 in slot 3... apples(3, true) # Pass 3 (the switch I want to manipulate) to apples and send it the value true to turn it on end if $game_actors[1].armor3_id != 2 #If he's NOT wearing it, turn the switch off. apples(3, false) end Like I said, it WORKS, but you have to equip, exit the menu, open it back up again, close the menu and it works. What's confusing to me is that if I just do a "step-on" switch for turning event 3 off/on, THAT works the second I step on it. There's got to be some type of "check to see if the switch is now on" that happens between the menu being opened/closed. Appreciate any help in advance, thanks!
×
×
  • Create New...