YEP event spawner - how to check meta properties of spawned event (solved)

Good day, my RPG fellows. I find myself obliged to ask for help. Again (sigh).

I'm creating my first MV game. It's a sort of crafting/survival game (pretty ambitious for my beginner skills, I'm aware of it) where player can crafts objects and tools. Generally, tools are used to craft or pick materials up, but some of these tools can be used only if the player is close to a... er... a structure (like hammer and forge).
So, I found a way to do this mechanic: checking the weapon (read: tool, like hammer) equipped, then save in a variable the name of the event (read: structure, like forge) and check it with conditional branches when the tool button is pressed. This works well and smooth with normal events but... doesn't with spawned events.
I'm using YEP event spawner (since, like I said, it's a crafting game). The process I came up with seems to not save the name of a spawned event (although it does save the event ID). Trying to do it, the game says:

Schermata 2019-10-22 alle 16.16.31.png

I also tried to check the note (the field at the right side of the event name) instead of the name. Again, this works with normal event, doesn't with spawned ones.

Indeed, I found a solution. It's a tortuous, very uncomfortable and easily-to-be-bugged eventing that checks the event properties. But I'd rather have a small script line, if possible, or even modify the plugin code.

Spoiler: YEP event spawner plugin:



Any help is appreciated. Thanks in advance and good eventing!
Can you share an image of the event page that you're having trouble with?
Can you share an image of the event page that you're having trouble with?

Ok, there's the screen cap.:

Spoiler
Schermata 2019-10-22 alle 22.00.40.png

Since my MV is in italian, I'll explain what is going on in the common event, just to be clear.
When the key assigned to the tool equipped is pressed, this event is called.
The first two variables save the actor coordinates, then the conditional branches and the event command 'get location info' serve to check if there is an event in front of the actor (and the ID event is stored in the variable 51). At the end, the script call saves the name of the event in a variable.
To let the game recognizes the type of event (and therefore recognizes if the tool can be used with that event), the name so found will be checked in other events.

This works with normal events. Maybe the code can be simplified, but it works well, except for spawned events.

I hope I was clear. Let me know if not.
Ah okay, I have a similar mechanic in my game, where the player can use a shovel and dig into the ground (like in Link's Awakening), but I do it differently than what you're doing.

Instead of having the game recognize the type of event with a name stored into a variable, have you tried making the game recognize the spawned event's x/y coordinates are equal to whatever you're interacting with?

I might be remembering it wrong, but this might not be possible with Yanfly's Event Spawner as this plugin doesn't let you spawn events on top of others. If that's the case, try looking into using Galv's Event Spawner, I believe you can put a special marker on events that allow you to spawn events on top of others, thus allowing you to check if their x/y coordinates are equal.
I might be remembering it wrong, but this might not be possible with Yanfly's Event Spawner as this plugin doesn't let you spawn events on top of others. If that's the case, try looking into using Galv's Event Spawner, I believe you can put a special marker on events that allow you to spawn events on top of others, thus allowing you to check if their x/y coordinates are equal.

You remember well. With Yanfly plugin, is not possible to spawn event in an occupied location. But I'm ok with this. I tried also Galv's plugin, but has the same problem: I can't save the event name of a spawned one.


Instead of having the game recognize the type of event with a name stored into a variable, have you tried making the game recognize the spawned event's x/y coordinates are equal to whatever you're interacting with?

Making so, how the game will be able to recognized the events? they are not predefined, but built by the player (thanks to Yanfly's plugin).

Perhaps I did not explain myself very well (due to my poor english, i bet).
In my game the player can creates different things. Some of these are immovable and take place in the map where the player wants they to be; these 'structures' serve to create better stuffs. The forge is an example: it let the player works the iron ore but to do so an instrument must be also equipped, the hammer. The same structure (like the forge) may be interacted with different instruments for different use, so I had to find a way to 'categorize' the structure, allowing multiple interaction. I tried the name check method, If there are more effective ways to do it, please tell me.
I just found a not too old thread with a similar problem (at least I think).

https://forums.rpgmakerweb.com/inde...anfly-event-spawner-not-handling-meta.107147/

The user ("Inqs") reported a bug of Yanfly's event spwaner plugin (the same I have troubles with):

It looks like the meta property of spawned events doesn't get set.

I presume that name and note tag of an event are meta properties - am I right?.
In my game, I tried to check one and the other, but without success. So, is this the same problem as mine?
Inqs only asked for a way to report to Yanfly. So, no solution of the problem was give to him. And I think he never succeeded to contact Yanfly, since the bug is still there.

Also, Inqs said:

I think a call to DataManager.extractMetadata() is necessary.

This code is something I can add myself to the plugin?

Thanks in advance for any help.
I think I'm starting to understand why the process does not work.
Maybe the plugin spawns events to the $gameMap instead of $dataMap. This may explain why the script I used ($dataMap.events[ID].name) does not work. Even assuming this is correct, I don't know how to solve this...
I think I'm starting to understand why the process does not work.
Maybe the plugin spawns events to the $gameMap instead of $dataMap. This may explain why the script I used ($dataMap.events[ID].name) does not work. Even assuming this is correct, I don't know how to solve this...
You're correct: $dataMap is the map as it is in the editor. 🙂

Maybe try this (I haven't tested it) in Control Variables > Script:
Code:
$gameMap.event($gameVariables.value(51)).event().name
You're correct: $dataMap is the map as it is in the editor. 🙂

Maybe try this (I haven't tested it) in Control Variables > Script:
Code:
$gameMap.event($gameVariables.value(51)).event().name

Thanks for replying. It's nice to know my idea wasn't wrong.
I tried the code you suggest me and it WORKS. Wow! thank you so much. I was getting desperate and then -yay- you saved the day. Also, It's comforting to know I'm slowly starting to comprehend the game.

So, just in case it is useful to anyone else, I used the code:

Code:
$gameVariables.setValue(x, $gameMap.event($gameVariables.value(y)).event().name)

where:
x: is the variable you want to store the spawned event's name;
y: is the ID of the spawned event.

Or more simply (as caethyril suggested):
Control Variables > Script > $gameMap.event($gameVariables.value(y)).event().name

Thank again so much, my hero. This thread can be finally and pleasantly closed.
Good eventing to you all!

Original thread: https://forums.rpgmakerweb.com/threads/yep-event-spawner-how-to-check-meta-properties-of-spawned-event-solved.114467/