Checking coordinates for a group of events

Sanguine

Hoot
Member
Joined
Oct 18, 2012
Messages
27
Reaction score
53
First Language
English
Primarily Uses
Hey all.

To check the coordinates of a single event, the script call in a conditional branch looks something like this:

$game_map.events[@event_id].x == 1 (For x coordinate 1)

$game_map.events[@event_id].y == 1 (For y coordinate 1)

My question is, is it possible to create a system of events to check for an array of events if they are at a specific position without creating more than 1 conditional branch? Something like

$game_map.events[001, 002, 003, 004].x == 1 

Or can this only be achieved with scripts? Thanks in advance.
 

KanaX

Just being a mouse
Veteran
Joined
Apr 3, 2013
Messages
1,463
Reaction score
1,285
First Language
Broken English.
Primarily Uses
N/A
What you want is called and array variable value.
 

Try calling this:

$game_variables[x] = [$game_map.events[1].x, $game_map.events[2].x, $game_map.events[3].x]

and after that set a conditional with a script like:

$game_variables[x] == [1, 1, 1]


I tested it and it works. Your only problem should be fitting the entire script call into one line.

EDIT: Okay, so I took it personally and I ended up finding a way to break the command to multiple lines. Your first script call should be like this:

$game_variables[x] = [$game_map.events[1].x, $game_map.events[2].x, \

$game_map.events[3].x, $game_map.events[4].y, $game_map.events[5].x, \

$game_map.events[6].y, $game_map.events[7].y]

That way, you can track as many events as you want.
 
Last edited by a moderator:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
1,483
Reaction score
982
First Language
English
Primarily Uses
$game_switches[id of an available switch] = [1, 2, 3, 5, 20, 42].all? { |event| $game_map.events[event].x == 1 }

Then you can use the switch in a conditional branch. This method allows as many event IDs as you want, they don't have to be sequential, and it'll all fit on a couple of lines at most.
 
Last edited by a moderator:

Sanguine

Hoot
Member
Joined
Oct 18, 2012
Messages
27
Reaction score
53
First Language
English
Primarily Uses
Thanks lots to both of you, I'll test it out and get back.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

So the overhaul on my project has been going great, I like this version of the project a lot more. It's more contained and less overly ambitious for what I can achieve given my constraints on time, money, and skills in advanced programming. I'm going to wait till my project is mostly finished to begin working UI polish again. I'm going to learn how to use LUNA MV to polish the project.
last time i used this site i was a different gender.. wow rlly makes u think... anyway transing ur gender is pretty cool and theres hair growing on my feet now 10/10
I should have listened to RPGMAKER Meme thread. I should have backed up my data. The Orphan of Time, my WIP, is completely gone, all those hours of work are completely gone :(
God what was my life before smartphones (I had a grandma's phone before wednesday)
Stream will be live shortly with The Witcher 3! Feel free to drop by!

Forum statistics

Threads
93,381
Messages
911,846
Members
122,882
Latest member
Jordan_Q
Top