iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Reply to this topicStart new topic
> Is there a script equivalent of "This event"?
cdabamsworth
post Jan 8 2012, 08:42 PM
Post #1


Jinjo
Group Icon


Type: Musician
Alignment: Lawful Good




At the moment, for my advanced boulder push thing, I use script calls like this (let's say the boulder is event ID 1):

$game_map.passable?($game_map.events[1].x, $game_map.events[1].y + 1)

The problem is, this is really boring, because if the boulder is event ID 2, it has to be this:

$game_map.passable?($game_map.events[2].x, $game_map.events[2].y + 1)

and if the boulder is event ID 3 it has to be this...

$game_map.passable?($game_map.events[3].x, $game_map.events[3].y + 1)

Doesn't seem that bad, but I use script calls like that around eight times per event to get all the different behaviours of the boulder in.

In drag & drop, rather than saying "event 2" or "event 8" you have the option to simply say "This event". Can I do that here? That way I would be able to copy and paste easily.
Go to the top of the page
 
+Quote Post
   
FenixFyreX
post Jan 9 2012, 01:19 AM
Post #2


I'm on fire 24/7 >:3
Group Icon


Type: Coder
Alignment: Lawful Good




CODE
class Game_Interpreter
  def get_ev(id)
    case id; when -1; return $game_player
    when 0; return $game_events[@event_id]
    else; return $game_events[id]
    end
  end
end


Now, just call:
CODE
get_ev(id)
to get an event.
-1 returns the player
0 returns the current event
1 or more returns an event by that id.

To get what you want, do:
CODE
$game_map.passable?(get_ev(0).x, get_ev(0).y + 1)
Because 0 returns the current event being processed, or "this event".
Go to the top of the page
 
+Quote Post
   
cdabamsworth
post Jan 10 2012, 08:52 AM
Post #3


Jinjo
Group Icon


Type: Musician
Alignment: Lawful Good




Thanks very much! biggrin.gif With a bit of tweaking it suits my needs great.

Thank you!
Go to the top of the page
 
+Quote Post
   
Raoul589
post Feb 18 2012, 11:47 AM
Post #4



Group Icon


Type: Coder
Alignment: Chaotic Good




An alternative way is to add this code to Game_Interpreter, in the method 'setup':

#--------------------------------------------------------------------------
# * Event Setup
# list : list of event commands
# event_id : event ID
#--------------------------------------------------------------------------
def setup(list, event_id = 0)
clear # Clear internal interpreter state
@map_id = $game_map.map_id # Memorize map ID
@original_event_id = event_id # Memorize event ID
@event_id = event_id # Memorize event ID

$t = $game_map.events[@event_id] # I ADDED THIS, SAME BELOW

@list = list # Memorize execution contents
@index = 0 # Initialize index
cancel_menu_call # Cancel menu call
end


if this is imbedded in the Interpreter code, you can use the global variable $t to mean the same thing as 'this', because the Interpreter will point $t to the event it is currently processing. Admittedly, this is virtually equivalent to FenixFyre's solution.
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: 2nd August 2014 - 07:43 AM

RPGMakerVX.net is an Privacy Policy, Legal.