So, out of boredom I decided to do this, I'll try to answer all script related questions regarding eventing. <.< Now don't blame me if you don't understand something. http://www.rpgmakervx.net/index.php?showforum=39 # << Start reading the stuff here if your a scripter/coder (even if your not) I'm not gonna explain the basics of ruby, I'm just gonna assume you have some knowledge of ruby by now. Now if your just starting RMVX, my advice, return self, learn the editor first. Some of the things here can be done without scripting.
-The FAQ- So I'll answer some of the most common questions.
Event Control Commands # - Its best to look at this first before continuing
Event Script Command # - This is the event script command
-BASICS- Just a few things I need to address before continuing. Data Types (only some though)
-ACTOR- *clears throat* Okay so everything here pretains to the Game_Actor class so anything done on the $game_actors[id] can be done on the $game_party.members[index] Assuming the actor exists.
QUES How do I get n party member? ANS
$game_party.members[member_index] # // NOTE member_index starts at 0 so if the party has 4 members, its 0, 1, 2, 3 as there indecies. # // Examples $game_party.members $game_party.members $game_party.members
QUES How do I get n Actor? ANS
$game_actors[actor_id] # // NOTE actor 0 is non existent, >.> unless a script put it there.
$game_map.events_xy(x, y) # // Note this returns an Array, if you have no idea what that is, go read a programming tut.
QUES How do I find if event/player is at x, y? ANS
#// 2 Ways #// 1 ($game_player.x == x and $game_player.y == y) ($game_map.events[event_id].x == x and $game_map.events[event_id].y == y) #// 2 $game_player.pos?(x, y) $game_map.events[event_id].pos?(x, y)
QUES How do I activate an event? ANS
$game_map.events[event_id].start # // NOTE be careful with this, you can actually chain activate events # // Examples $game_map.events.start $game_map.events.start $game_map.events.start
-CONDITIONS- Ahh yeah~ I'm not gonna get into cases .
if sumthing do_stuff elsif sumthing_else do_other_stuff else do_else_stuff end
# // Note unless is the opposite of if unless sumthing do_stuff elsif sumthing_else do_other_stuff else do_else_stuff end
QUES How do I get the current maps ID? ANS
QUES How do I get the tile_id at x, y? ANS
$game_map.data[x, y, z] # // NOTE The data object for a map is a Table with 3 layers; (0, 1, 2) it starts at 0. # // This first layer is all your A tiles (except some, like the tall grass for eg) # // The second layer is where the other overlaying A tiles go # // The third layer is Tiles B to E
# // Examples $game_map.data[1, 1, 2] Returns the B~E tile_id at 1, 1
$game_map.data[1, 1, 0] Returns the B~E tile_id at 1, 1
>.> If you want to get the tile_id for the tile the player is currently standing on... Use the knowledge you gained from above...
-ALL TOGETHER NOW- I'm gonna pull some stunts that weren't mentioned okay.
# // Get Player's XY and see if it matches Event 2 px = $game_player.x py = $game_player.y if $game_map.events.pos?(px, py) p "Positions Match" else p "Positions do not Match" end
# // A more useful version, assigning the value to switch 5 px = $game_player.x py = $game_player.y val= $game_map.events.pos?(px, py) $game_switches = val
# // Getting the first party members level and storing it in variable 10 mem = $game_party.members $game_variables = mem.level
# // But WHAT IF X doesn't exist? # // NOTE nil is the... what ya call the, null, valueless, errr value(-less)... mem = $game_party.members unless mem == nil mem = $game_party.members $game_variables = mem.level end
# // Last Modified 05/02/2011
If you have a question, and it somehow, wasn't covered feel free to post here about it.
This post has been edited by IceDragon: May 6 2011, 08:35 PM