Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Dynamic Active event tracking

Reno Kugler

Villager
Xy$
0.00
So I'm making a puzzle game, and while I could make a rediculous amount of switches and a parallel process to use the Outer Self Switch addon from Kadokawa... I'd rather have a script to make the whole process... easier. But I'm not very "Hip" with the coding language (enough to learn when it's broken down but I certainly am not an author). Using a code previously posted here

JavaScript:
$gameVariables.setValue(0893, $dataMap.events[this._eventId].id);
I have it set to record an event ID from a rock after it's touched by a player. I want to run a parallel process that uses that variable to check the events location on the map (so it'll actively check the location and apply the x and y to two other variables labeled Active X and Active Y) and then make a list of locations where I have pits or switches. If it's on the pit or switch I can use outer self switch commands to do the rest.

Basically: I need (or rather, want) a script that can take an event ID and apply its location to two other variables.
 
Last edited:

Reno Kugler

Villager
Xy$
0.00
After a LOT of trial and error and resource gathering I finally made a working line of code. I'll post the solution for anyone who happens upon this.

First label 5 variables for the following
Active Event: (AE)
Active Events X position (AX)
Active Events Y position (AY)
Active Events Old X Position (OX)
Active Events Old Y Position (OY)
Put this code on the objects you're moving
JavaScript:
$gameVariables.setValue(AE, $dataMap.events[this._eventId].id);

$gameVariables.setValue(OX, $gameMap.events()[$gameVariables.value(AE)-1].x); //the -1 is needed I assume because the () makes it an array, which starts counting at 0 instead of 1.

$gameVariables.setValue(OY, $gameMap.events()[$gameVariables.value(AE)-1].y);
Now make an event that is a parallel process and make two conditional branches

one for if OX and AX aren't equal
and another for if OY and AY aren't equal.

for OX !== AX put
JavaScript:
$gameVariables.setValue(AX, $gameMap.events()[$gameVariables.value(AE)-1].x);
and then add a control variables command that sets OX=AX
and for OY !== AY put
JavaScript:
$gameVariables.setValue(AY, $gameMap.events()[$gameVariables.value(AE)-1].y);
and then add a control variables command that sets OY=AY
 
Top