$game_map.events[My_Variable] not a static event id

Status
Not open for further replies.

nihilath

Villager
Member
Joined
Jul 6, 2014
Messages
21
Reaction score
2
Primarily Uses
As the title says, I am looking for a way to pass a dynamic variable to $game_map.events[] so I can use it in a condition with changing event_ids.

The point is that I have multiple "enemy events" which can be killed if they touch another event which has to be activated by the player. A trap basically. If the player activates the trap event, the event_id is passed to a variable. If the enemy is near the trap (that part already works), it should check, if the event_id of the trap is the activated one, which was passed to the variable earlier.

This is the code I would use in a conditional branch, on the "enemy event" as a script, but I couldnt find a way to pass a variable:

$game_map.events[event_id].x - $game_map.events[My_Variable].x + $game_map.events[event_id].y - $game_map.events[My_Variable].y <= 1

Any idea?

Hope thats the right place, I am new to the forum...
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
why don't you use the event variables?


$game_variables[id] where ID is the number of the general variable - that way you can even use the control variable command to set or check which event is currently triggered.
 

nihilath

Villager
Member
Joined
Jul 6, 2014
Messages
21
Reaction score
2
Primarily Uses
why don't you use the event variables?

$game_variables[id] where ID is the number of the general variable - that way you can even use the control variable command to set or check which event is currently triggered.
How would I use them in the context of a condition? Because something like this:

MyEventId = $game_variables[21]

$game_map.events[MyEventId].x <= 1

doesnt seem to work in a conditional branch :(
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
How would I use them in the context of a condition? Because something like this:

MyEventId = $game_variables[21]

$game_map.events[MyEventId].x <= 1

doesnt seem to work in a conditional branch :(
Of course not - you have only a single script line for the conditional branches.That means that

$game_map.events[$game_variables[21]].x <=1does work in a conditional branch.Edit:

You need to make sure that the event ID stored in the variable does exist on that specific map however, all maps have their own list of events...
 
Last edited by a moderator:

nihilath

Villager
Member
Joined
Jul 6, 2014
Messages
21
Reaction score
2
Primarily Uses
That worked. Thanks! Didnt come to my mind to write the variable definition directly in the event -.-
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top