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
984
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

Jamaica? No, Aunty. I said, I'm on RPG Maker :*/
Lunar New Year is over :( but it's time to get back to work!
I keep giving myself deadlines because I'm so excited to finish something but I notice areas where I'm rushing the story and that's what's gonna weaken my overall project, gotta stop that
My new level features a Jellyfish character who cannot love, because he electrocutes everything he touches.
I prefer single roommates. After a hard day, all you want is sleep. I went to bed at 12. I was awakened at 2 because of my roommate laughing and whispering and stuff with her boyfriend on the phone. I didn't want to yell at her so I had to bear that cringy lovey dovey convo for half an hour, before I got so bored that I fell asleep again.

Forum statistics

Threads
93,688
Messages
914,639
Members
123,285
Latest member
jojojovil
Top