First off a few details so everyone can understand what I want to make and why.
The game contains two possible Actors.
The game also contains two possible Classes.
Actor 1 is Class 1 and Actor 2 is Class 2.
This is RPG Maker basics, but I needed to state how things are set up, so you would understand easier what I am trying to do.
So I want to make npcs say something like:
Class: Name:
Officer Johnson
Captain Jack
Thus I thought that
\V[1] \N[1]
would be a fine way to do that.
But I should add the class name to variable 1 first. That's what I try to achieve really.
So....
I ran that script...
$gameVariables[1] = $game_actors[1].class.name;
and got a reference error
"game_actors is not defined"
Isn't game_actors scope global? I mean, why wouldn't I access it from eventing?
If not, please consider giving me a way to refer to the data through Script or Plugin command, Event command.
If possible please explain why and how your way works, so I can also hopefully understand what is going on here. :p
Also:
Feel free to share alternative ways to show class name.
Thanks in advance guys.
$game actors is not defined. Why?
● ARCHIVED · READ-ONLY
-
-
when and where did you run the line?
All gamedata is only initialised on "new game", if that line is executed before the new game happens (for example while still on the title screen), then everything is undefined. -
This is not VXAce, the namespace is not $game_something, but $gameSomething.
So not $game_actors, but $gameActors. -
Thanks @Poryg, you are right. So I was using wrong name.
@Archeia, the mv list of event commands, should be corrected then.
I did a copy- paste from there and that was an issue.
Part to correct:
Spoiler# Checking Actors
# ----------------------------------------------
$game_actors[X].name # Returns the name of the actor X
$game_actors[X].nickname # Returns the nickname of the actor X
$game_actors[X].class.id # Returns the ID of the actor X class
$game_actors[X].class.name # Returns the name of the actor X class
@Poryg what you suggested though, throws now another error.
A TypeError.
Cannot read property of 'class' of undefined.
Here is the script command I tried.
$gameVariables[1] = $gameActors[1].class.name;
Edit:
@Andar, I ran this command after the game starts so I can initialize Variable #001. -
what are you talking about @Dreadshadow
You're checking the VXAce equivalent of the MV commands in the spreadsheet.
-
what are you talking about @Dreadshadow
You're checking the VXAce equivalent of the MV commands in the spreadsheet.
OH! :eswt::eswt::eswt::eswt::eswt::eswt::eswt::eswt:
Can't stop laughing at myself right now on how stupid my mistake was. :p
Thus I end up doing this:
$gameVariables[1] = $gameActors.actor(1).currentClass().name
But \V[1] now rerturns 0.
I mean, shouldn't it return a string or something?
Self fixed a bug I caused myself nevermind that, I had a command redefining its value.
$gameActors.actor(1).currentClass().name
So Actually through Control Variables, the command worked like a charm.
Thank you @Archeia! -
[closed]IgnoreMe[/closed]