getting an event's name?

Doktor_Q

I'm not a real doktor, but I am a real Q
Veteran
Joined
Aug 1, 2016
Messages
875
Reaction score
563
First Language
English
Primarily Uses
RMMV
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?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Where are you putting that call?  If it's in a script, the scope is Game_Interpreter, which doesn't have an event() function.
 

Ahuramazda

Veteran
Veteran
Joined
Nov 9, 2012
Messages
262
Reaction score
127
First Language
English
Primarily Uses
RMMZ
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 :D
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
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.
 

Ahuramazda

Veteran
Veteran
Joined
Nov 9, 2012
Messages
262
Reaction score
127
First Language
English
Primarily Uses
RMMZ
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. :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
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.
 

Ahuramazda

Veteran
Veteran
Joined
Nov 9, 2012
Messages
262
Reaction score
127
First Language
English
Primarily Uses
RMMZ
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 :D
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Yeah, I made a reference to your answer when I said it also uses the Game_Interpreter context.  Many ways to do it.
 

Doktor_Q

I'm not a real doktor, but I am a real Q
Veteran
Joined
Aug 1, 2016
Messages
875
Reaction score
563
First Language
English
Primarily Uses
RMMV
Oh well that explains a lot. I'll use that then, thanks.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top