Announcement
Announcement
| 2nd Quarter Contest Announcement posted! See the Community Announcements section. |
![]() ![]() |
Jan 8 2012, 08:42 PM
Post
#1
|
|
|
Jinjo ![]() 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. |
|
|
|
Jan 9 2012, 01:19 AM
Post
#2
|
|
![]() I'm on fire 24/7 >:3 ![]() 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".
|
|
|
|
Jan 10 2012, 08:52 AM
Post
#3
|
|
|
Jinjo ![]() Type: Musician Alignment: Lawful Good |
Thanks very much!
Thank you! |
|
|
|
Feb 18 2012, 11:47 AM
Post
#4
|
|
![]() ![]() 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. |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 20th May 2013 - 08:26 PM |
|
|