I'm trying to make use of the data I entered in the editor, in this case, defining the event's name (the string), then pulling that into a variable via a Script line. Unfortunately, I can't seem to find out how to actually get the name- I tried this.event().name, but that's complaining about undefined functions, so I think my "this" is probably not what I'm expecting.
Short version: How do I access the event's "name" property from the editor inside a script call?
Where are you putting that call? If it's in a script, the scope is Game_Interpreter, which doesn't have an event() function.
Using this line of code allows me to change a variable to having this as its value and show up in a chat box, so its pulling the name from the event that is calling it.
$gameVariables.setValue(22, $dataMap.events[this._eventId].name)
put this in a script call in the event you want to check its name and then have a message box show the value for variable 22 (or whatever variable you set it to) to make sure it works for you as well 😀
this.event().name will work as well, as long as it's run from a Game_Event object. If it's a script command in an event, that's run by a Game_Interpreter object, so this is the Game_Interpreter, not the event. In that case (from a script command), you would do this.character(0).event().name to get the name of the event that contains the script call.
The answer above also uses this in the Game_Interpreter context.
Using the line I suggested they could also get the name of other events easily by changing the "this._eventId" to whatever the ID of the desired event is...
$gameVariables.setValue(X, $dataMap.events[Y].name)
X = the variable ID you want to set the name to for calling it
Y = event ID you want to pull the name from
so if you had an event running, but wanted to catch the name of another event an turn it into the variable you could. Not so sure I could do the same thing with your code Shaz? I'm not able to test right now to see, so I'm just running on memory. 🙂
The OP used this which indicates they wanted the current event, not a different one 😉 This isn't a competition - I was just providing another way to access "this" event, which is the way the Game_Interpreter script does it.
That's why my original thing said 'this' as well, but I didn't mean for it to sound like competition XD
Different ways to do things differently can come in handy and I'll keep it in mind 😀
Yeah, I made a reference to your answer when I said it also uses the Game_Interpreter context. Many ways to do it.
Oh well that explains a lot. I'll use that then, thanks.