Set variable to this._eventID [SOLVED]

Hello!

I am having issues with Galvs event detector. Im trying to have the current event be the actual detector as I am using it in accordance with his event spawner, so the detector ID will keep changing. And as far as I've been able to find out, there is no built in feature in his detector to just use this event to be the detector.

So I tried setting an event to the static events id number, in this case it's 28. And then tried calling the variable script for the detector as shown below.
Galv.DETECT.event($gameVariables.value(78),8,false)

So setting the variable 78 to 28 works and trigger the event. It's also worth mentioning that the variable 78 is a self variable.

But when using below code to set the same event
$gameVariables.setValue(78, $dataMap.events[this._eventId].id);
console.log($gameVariables.value(78));


However now, it does not work. Even though I've set the self variable to the eventID and also verified in F9 that var 78 = 28.
But now neither the static or the spawned event works.

Altough using the below will work for the static event but not the spawned event.

But when using below code to set the same event
$gameVariables.setValue(129, $dataMap.events[this._eventId].id);
console.log($gameVariables.value(129));

When the spawned event spawns, it does not event set a value to 129, but the static one would.

So selfvariables don't work unless specified that it's 28, with script it does not work.
The variable does not get set if the event has spawned.

Pictures below of the different things will be posted below which in my opinion is way more clear than my convoluded explanation.
https://gyazo.com/a5b3a1d0ed34e5f1dd9639a82a52e008

Best regards,
Bishiba

So I am quite curious, how do I set a variable
Code:
$gameVariables.setValue(78, $dataMap.events[this._eventId].id);

This is just weird.

this._eventId is the id of the current event.
You are retrieving the event from $dataMap.events using this._eventId.
Then you are getting the id of that event.

It is going to be this._eventId

Just use
Code:
$gameVariables.setValue(78, this._eventId);

Whether it will work for your purpose or not I don't know - I'm just pointing out that you're using the id to retrieve the event so you can get the id from the event. You've already got the id.
Code:
$gameVariables.setValue(78, $dataMap.events[this._eventId].id);

This is just weird.

this._eventId is the id of the current event.
You are retrieving the event from $dataMap.events using this._eventId.
Then you are getting the id of that event.

It is going to be this._eventId

Just use
Code:
$gameVariables.setValue(78, this._eventId);

Whether it will work for your purpose or not I don't know - I'm just pointing out that you're using the id to retrieve the event so you can get the id from the event. You've already got the id.

Yeah, I know it's weird, but the standard $gameVairbale.setValue(x, y) doesn't even work, so this._eventID works even less i would imagine. At least the weird one gets the proper eventID... It's so messed up. Or rather, I know that this._eventID doesn't work as it was the first thing I tried. Both in pure script and with the UI control variables script area.

https://gyazo.com/c88b41262529e942f812c7f8d9e449df
Works without fault for the static event.
So I have concluded that spawned events lack eventIDs if they are called in scripts, but they work perfectly fine if you use them in movement routes and stuff...

upload_2017-10-11_10-46-9.png


upload_2017-10-11_10-51-24.png
Ah! Spawned events won't be on $dataMap because that's what existed when you saved your map design in the editor. Before anything was spawned.

Try $gameMap.event(this._eventId)

But I still reckon you should only need to use this._eventId because you're running it in the interpreter.

If this._eventId doesn't return a correct value, then $gameMap.event(this._eventId) and $dataMap.events[this._eventId] won't work either, because you're using the same this._eventId for all the calls.
Ah! Spawned events won't be on $dataMap because that's what existed when you saved your map design in the editor. Before anything was spawned.

Try $gameMap.event(this._eventId)

But I still reckon you should only need to use this._eventId because you're running it in the interpreter.

If this._eventId doesn't return a correct value, then $gameMap.event(this._eventId) and $dataMap.events[this._eventId] won't work either, because you're using the same this._eventId for all the calls.
Static Event with your suggestion:
upload_2017-10-11_10-55-43.png

upload_2017-10-11_10-57-19.png


PS. I also tried replacing $dataMap.event[this._eventid] with simply this._eventid

No Idea why, but now the event works when I use this._eventId... Miracle I suppose. Thread can be closed.
You put it in wrong. I didn't say to replace the whole thing with $gameMap.event(this._eventId) - I simply meant to replace $dataMap.events[this._eventId] with it.

You've got to try to understand what you're passing in. $gameMap.event(this._eventId) is passing in an event object. this._eventId is passing in a number.

It is not a miracle. It works because this._eventId is a number, and $gameMap(this._eventId) is not, and $dataMap.events[this._eventId] does not exist for a spawned event.

Report the thread and ask the moderators to close it 😉

Original thread: https://forums.rpgmakerweb.com/threads/set-variable-to-this-_eventid-solved.85542/