How write text into the note tag zone of an event with a script command ?

Hi,

I think I already did it, but I cant remember.

I know how to "read" the note tag of an event with
Code:
$gameMap.event(ID OF THE EVENT).event().note
but I dont remember how "to write" inside with a script command (Edited to add "with a script command" xD ).

Someone have an idea please ?
Hi there!
1648350593749.png
xD you killed me xD ...

With a script command of course 😠.
(I will add this detail to the original post 😛 )
xD you killed me xD ...

With a script command of course 😠.
(I will add this detail to the original post 😛 )
haha sorry xD

You can use that same approach:
$gameMap.event(ID OF THE EVENT).event().note = "your content here"

But this will also erase previous notes. If you want to just add:

$gameMap.event(ID OF THE EVENT).event().note += "Your content here"

But any changes you made on that will not be saved on the save file or when you change maps.
Code:
Cannot read property 'event' of undefined

I already tried it.

I also tried to use the Yanfly Self Variable to remotely change the local variable of my event, this did work but I must try again, I think I made a mistake when I wrote the code.

EDIT : Hmmm no, this seems to dont work even when I'm sure of the code inside the plugin command zone :
Code:
Script :

$gameVariables.setValue(33, $gameMap.event(this.eventId()).event().note);

Plugin Command :
SelfVariable Map 1, Event $gameMap.LastSpawnedEvent(), Variable 32 to $gameVariables.value(33)

Here, I created a transitionnal variable (33, global) to be sure it was not an issue about the "$gameMap.event(this.eventId()).event().note)". This copy the data inside 33 inside the local variable 32 of the last event spawned.
Can you show exactly the script code you tried?
This is supposed to work just fine.
1648353867389.png


Cannot read property 'event' of undefined
This means that there is no event with the ID informed.
So when the code does:
$gameMap.event(ID OF THE EVENT)
This is returning undefined.
So when he tries to get the event data using .event(), the error shows up.
Code:
$gameMap.event($gameMap.LastSpawnedEvent()).event().note = 41

EDIT : Of course, just before I create a clone :

Code:
Yanfly.SpawnEventAt(5, 63, $gameMap.event(this.eventId()).x, $gameMap.event(this.eventId()).y +1, true)

EDIT2 : To return on the subject of the local variable, I probably forgot to write "$gameMap.event(" before "$gameMap.LastSpawnedEvent()" and ")", but it still doesnt work with this fix 🙁 .

EDIT3 : I forgot there is already a fonction $gameMap.LastSpawnedEventID() for that. Same result of course for :

Code:
$gameMap.LastSpawnedEventID().event().note = 41

And

Code:
SelfVariable Map 1, Event $gameMap.LastSpawnedEventID(), Variable 32 to $gameVariables.value(33)

EDIT4 : Maybe I made a mistake and I didnt understand what was a plugin command. There is a script command for remotely change a Self Variable :

Code:
this.setSelfVariableValue(1,$gameMap.LastSpawnedEventID(),32,$gameMap.event(this.eventId()).event().note)

Still doesnt work...

EDIT5 : My issue is here, the $gameMap.LastSpawnedEventID() dont give me the ID that I need, I tried to put it inside a var, the reading the var with a message box, answer : 0......... I dont understand why, everything else is working !

EDIT6 : I dont understand why "$gameMap.LastSpawnedEvent()" works perfectly fine but "$gameMap.LastSpawnedEventID()" and "$gameMap.event($gameMap.LastSpawnedEvent())"
doesnt at all... It's like I changed something and now it doesnt work....... But IDK what...
My issue is here, the $gameMap.LastSpawnedEventID() dont give me the ID that I need, I tried to put it inside a var, the reading the var with a message box, answer : 0......... I dont understand why, everything else is working !

Is "ID" supposed to be "Id"? I know capitalization matters in script calls.
On the official page it's written like that :

Code:
  $gameMap.LastSpawnedEvent()
  - This will grab the last available spawned event as an object.
  - If the last event has been despawned, the previous event in the list
    will be returned as an object. If there are no spawned events left, this
    script call will return an undefined value.

  - - -

  $gameMap.LastSpawnedEventID()
  - This will grab the last available spawned event's ID as a number.
  - If the last event has been despawned, the previous event ID on in the
    list will be returned as a number. If there are no spawned events left,
    this script call will return a value of 0.

And there is a similar result with "$gameMap.event($gameMap.LastSpawnedEvent())".
Code:
$gameMap.event($gameMap.LastSpawnedEvent()).event().note = 41

EDIT : Of course, just before I create a clone :

Code:
Yanfly.SpawnEventAt(5, 63, $gameMap.event(this.eventId()).x, $gameMap.event(this.eventId()).y +1, true)

EDIT2 : To return on the subject of the local variable, I probably forgot to write "$gameMap.event(" before "$gameMap.LastSpawnedEvent()" and ")", but it still doesnt work with this fix 🙁 .

EDIT3 : I forgot there is already a fonction $gameMap.LastSpawnedEventID() for that. Same result of course for :

Code:
$gameMap.LastSpawnedEventID().event().note = 41

And

Code:
SelfVariable Map 1, Event $gameMap.LastSpawnedEventID(), Variable 32 to $gameVariables.value(33)

EDIT4 : Maybe I made a mistake and I didnt understand what was a plugin command. There is a script command for remotely change a Self Variable :

Code:
this.setSelfVariableValue(1,$gameMap.LastSpawnedEventID(),32,$gameMap.event(this.eventId()).event().note)

Still doesnt work...

EDIT5 : My issue is here, the $gameMap.LastSpawnedEventID() dont give me the ID that I need, I tried to put it inside a var, the reading the var with a message box, answer : 0......... I dont understand why, everything else is working !

EDIT6 : I dont understand why "$gameMap.LastSpawnedEvent()" works perfectly fine but "$gameMap.LastSpawnedEventID()" and "$gameMap.event($gameMap.LastSpawnedEvent())"
doesnt at all... It's like I changed something and now it doesnt work....... But IDK what...
Oh sorry, I don't know these plugins, so I can't help you with that.
But the code definitely is:
$gameMap.event(ID OF THE EVENT).event().note

Next time is better if you already insert on your post the plugins you are using to try to achieve your results ^^
Indeed.

I didnt think it was related to it since it was working everywhere else.
@Nemesis666 Hmm... Another thing is that I believe there are supposed to be spaces between the parameters in YEP's this.setSelfVariableValue script call. Does that change anything?

Edit: ALSO (I don't know why this would matter as long as there is an ID, but covering all the bases I guess), if you open the Event Spawner in the plugin manager, what number is it set to start the spawned events' IDs at?
Same result with space before parameters.

Maybe it's the $ symbol, I dont know why I have this kind of feelings...

EDIT : Let's remember that I cant get the ID of the cloned event... And this is really weird because on an other event I did put
$gameVariables.setValue($gameMap.event(this.eventId()).event().note, $gameMap.LastSpawnedEventID()); " and
"Yanfly.DespawnEventID($gameVariables.value($gameMap.event(this.eventId()).event().note));" and this work perfectly fine........

EDIT2 : I checked again, and the only conclusion is that Local Variables are not compatible with EventSpawner, even when I store them in a transitionnal variable... Maybe it's because they start by 1001, IDK...
EDIT3 : The official page of the mod announce to be able to go "at least" to "12345", so, this is not the problem...
$gameVariables.setValue($gameMap.event(this.eventId()).event().note, $gameMap.LastSpawnedEventID()); "
Ah, well, this is backwards isn't it? I thought it was the variable ID first and then the value you're setting it to?

Unless I'm misunderstanding what you're trying to do? Where you have the "$gameMap.event(this.eventId()).event().note" is where there should be the value of the variable you're trying to set, so I'm not sure how that would work?

Edit: Except you said it did work, so actually now I'm just more confused haha... I guess I need a clearer understanding of what exactly these script calls are supposed to be doing?
$gameMap.LastSpawnedEventID() takes the ID of the last clone created. Let's call it B.
$gameMap.event(this.eventId()).event().note reads the note of "this" event. Let's call it A.
$gameVariables.setValue(A, B ) set a value B inside the Var A.

I will try the local var system of Eliaquim https://hakuenstudio.itch.io/eli-self-variables-for-rpg-maker-mz

Hoping it works for MV.

Now I will sleep, I'm working on this case since 8h and I didnt sleep tonight because of this problem, my eyes and my brain are broken xD .
@Nemesis666 Ooh, so you're storing the ID of the variable you want to set in the event's notebox? So when it reads the value of the note it'll just be a number value corresponding to the variable ID? Gotta say, I've never thought of that - pretty clever and good to know it works, if that ever needs to come in handy 🙂

But yeah, otherwise I have no idea why you can't retrieve the spawned event's ID. Sorry! I hope Eliaquim's system works better, although I'm not sure why it would if the issue is with the Event Spawner script call? Either way I'll be interested to find out 🙂 Rest well!
Good news, the Self Variables mod of Eli works for storing the value of the last event spawned.

Now, I have to figured out how to remotely change a self var.

EDIT : "$gameVariables.selfValue(mapid, eventid, selfvarid);" and "$gameVariables.setSelfValue([mapid, eventid, selfvarid], value);" return an error "$gameVariables.selfValue/$gameVariables.setSelfValue is not a fonction"...

EDIT2 : It's not written inside the description of the plugin, but it seems the Eli's Book is need for using these fonctions. So, now I dont have errors, but I tried with and without [], but I cant address a distant selfvar.

EDIT3 : In fact, I made a mistake, the mod of Eli is not replacing a global var by a local var, this ADD a local var ON a global var, this mean in my first test, I did set the global var, not the local var...

EDIT4 : Let's resume :

Code:
$gameVariables.setValue(33, $gameMap.event(this.eventId()).event().note);

I take a data (Here, the notetag), and I store it into the Global Var 33. It works.

Code:
this.setSv(32, $gameVariables.value(33));

Now, I store the content of the global var 33 into the local var 32. I dont know if it works at this step.

Code:
\sv[32]

To check if the previous code was working, I create a text box where I show the local var 32 with the help of the Escape Codes of @Eliaquim. This return... 0...

Code:
 this.setSv(32, 1);

To control that's not related to the content of the Global Var 33, I set the local var 32 to 1. Dont work...

EDIT5 : Return to the starting case. I take again the first ID of the topic : taking the note tag from an event and puting it in an other event. Using global variable, this work for one event, but if I do it for 2 events, this fail. Maybe it's because it's a parallele event, I will set it in automatic.

EDIT6 : Okay, I'm making progress, but I have a strange behavior :
Autorun must FREEZE all other event, right ?
So, where is the issue :
Code:
Yanfly.SpawnEventAt(5, 63, $gameMap.event(this.eventId()).x, $gameMap.event(this.eventId()).y +1, true);
Step 1 : Creating an event.

Code:
$gameVariables.setValue(33, $gameMap.event(this.eventId()).event().note);
Step 2 : puting note of this event into the global var 33.

Code:
$gameVariables.setValue(32, $gameMap.LastSpawnedEventID());
Step 3 : puting the number of the event we created in the step 1 onto the global var 32.

Code:
$gameMap.event($gameVariables.value(32)).event().note = $gameVariables.value(33)
Step 4 : puting the data inside the glob var 33 into the note of the event number "stored in the glob. var. 32".

Until now, it works.

Step 5, doing everthing previously from an other event spawner.

Step 1, 2, 3, seems okay.

Step 4 : it is applying the note to EVERY PREVIOUS SPAWNED EVENTS !!!!!!!!!!!!!!!!!!!!!!!!!!!!! WHAT DA FAK !?????????

EDIT6 : I'm 100% sure the lastspawnedeventID return to me the right data, I did draw 2 text boxes, the results about their ID are correct.

I did write the previous steps into one line to avoid any perturbation on variables (32 & 33) :

Code:
$gameMap.event($gameMap.LastSpawnedEventID()).event().note = $gameMap.event(this.eventId()).event().note

<= this should not write on multiple event, only on one........ WHY does it do that !!§????

Original thread: https://forums.rpgmakerweb.com/threads/how-write-text-into-the-note-tag-zone-of-an-event-with-a-script-command.146164/