Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Sign in to follow this  
  • entries
    7
  • comments
    2
  • views
    3,669

Waiting for movement's completion

Sign in to follow this  
Zeriab

267 views

To show one use of my Interpreter command_355 fix I'll show how you can make events wait for movement of a single event or the player to finish rather than all movements which the Wait For Move's Completion command does.

Let's add this little snippet for checking whether Game_Character is moving or not. (Both Game_Player and Game_Event inherits from that class: (Add anywhere above main)

 

http://paste-bin.com/view/6af9b1c2

 

It returns :wait when called. You can now put $game_player.wait_for_movement in a script call and that event will wait until the player has stopped moving before continuing.

Likewise you can use $game_map.events[7].wait_for_movement for waiting until the event with id 7 has finished its movement.

It's simple, elegant and much easier than had the wait functionality been removed from command_355. It was an excellent idea in the default scripts albeit a little poorly executed and unfortunately not well-understood.

 

Next I will add some syntactic sugar to use in the call scripts which makes waiting for specific events easier. It's not needed at all, but it is more user friendly and nicer to use.

Add this script anywhere above main: (Script put at bottom)

 

You can now simply put wait_for_movement in a script call and it will wait for its own movement to to be completed. (Note that it will simply skip if the interpreter does not originate from a map event. See my Common Events tutorial for more information on this subject)

You can specify a specific with wait_for_movement(id) where id is the id of the map event. If you for example want to wait for event 7 then use wait_for_movement(7).

You can wait for the player by using wait_for_movement(0) or by using wait_for_players_movement.

 

Note that it will do nothing if called in battle.

 

class Interpreter
 ##
 # Wait for movement where: (Nothing will happen in combat)
 # id < 0: Current event (if there is one)
 # id = 0: Player
 # id > 0: Event with that id (if there is one)
 #
 def wait_for_movement(id = -1)
   # If in battle
   return if $game_temp.in_battle
   # Get actor
   actor = nil
   if id < 0 && @event_id > 0
     actor = $game_map.events[@event_id]
   elsif id == 0
     actor = $game_player
   else
     actor = $game_map.events[id]
   end
   # Wait for actor's movement
   unless actor.nil?
     actor.wait_for_movement
   end
 end
 ##
 # Wait for player's movement
 #
 def wait_for_players_movement
   wait_for_movement(0)
 end
end

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...