Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Pokémon Essentials
Reload this Page [Question] Checking for event names in script help

Notices
For all updates, view the main page.

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.



Reply
 
Thread Tools
  #1    
Old January 2nd, 2014 (08:44 PM).
Rayd12smitty's Avatar
Rayd12smitty Rayd12smitty is offline
Shadow Maker
 
Join Date: Dec 2011
Gender: Male
Posts: 642
I am trying to make something run for every event on the map, but only if that event has a certain name. I have this
Code:
    for event in 0...$game_map.events.length
      pbMoveRoute($game_map.events[event],[PBMoveRoute::StepAnimeOn])
    end
which works perfectly for every event on the map. I only want the events named "Poke" though. I tried this
Code:
    for event in 0...$game_map.events.length
      if event.name=="Poke"
        pbMoveRoute($game_map.events[event],[PBMoveRoute::StepAnimeOn])
      end
    end
I get an error. I have tried doing other methods with using $game_map.events.values instead but I can't get any events to move when I do that, although the game doesn't crash. I'm kinda lost here. Can anyone help?
__________________
Reply With Quote
  #2    
Old January 2nd, 2014 (09:08 PM).
~JV~'s Avatar
~JV~ ~JV~ is offline
Dev of Pokémon Uranium
 
Join Date: Aug 2007
Location: Rio de Janeiro
Age: 21
Nature: Relaxed
Posts: 712
Send a message via Skype™ to ~JV~
the variable is returning a number between 0 and the total number of events on the map, so trying to get a .name from it won't work. What you should do to get the actual event is use:

Code:
for event in $game_map.events.values
instead of:

Code:
for event in 0...$game_map.events.length
__________________
Reply With Quote
  #3    
Old January 2nd, 2014 (09:20 PM).
Rayd12smitty's Avatar
Rayd12smitty Rayd12smitty is offline
Shadow Maker
 
Join Date: Dec 2011
Gender: Male
Posts: 642
Quote originally posted by ~JV~:
the variable is returning a number between 0 and the total number of events on the map, so trying to get a .name from it won't work. What you should do to get the actual event is use:

Code:
for event in $game_map.events.values
instead of:

Code:
for event in 0...$game_map.events.length
Alright I get no error now, but nothing happens. I took away the name check but the animation/move route doesn't happen on any of the events with or without the name check.

This is the whole script
Code:
  def update_stepping
    FollowingMoveRoute([PBMoveRoute::StepAnimeOn])
    for event in $game_map.events.values
      if event.name=="Poke"
        pbMoveRoute($game_map.events[event],[PBMoveRoute::StepAnimeOn])
      end
    end
  end
You can ignore the FollowingMoveRoute part. I am trying to add something to the Following Pokemon script I am working on. This "update_stepping" is called whenever the map updates pretty much so it's constant. The update for the Following Pokemon sprite works perfectly. I want to make the same effect work for any event named "Poke"
__________________
Reply With Quote
  #4    
Old January 3rd, 2014 (03:18 AM).
Maruno's Avatar
Maruno Maruno is offline
Lead Dev of Pokémon Essentials
Moderator
 
Join Date: Jan 2008
Location: England
Posts: 3,979
It looks like you're getting confused about what you're looping through.

Code:
for event in $game_map.events.values
event is an event. It's not a number. event.name works fine, because events have names, but $game_map.events[event] is nonsensical because it expects event to be a number and would give the event with that number.

Replace $game_map.events[event] with event.
__________________
Reply With Quote
  #5    
Old January 3rd, 2014 (09:48 AM).
Rayd12smitty's Avatar
Rayd12smitty Rayd12smitty is offline
Shadow Maker
 
Join Date: Dec 2011
Gender: Male
Posts: 642
Thank you so much! I wasn't sure exactly what these values were or returned. I was just trying to look at other scripts and try to figure out how to make it run.
__________________
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are UTC -8. The time now is 11:49 PM.