Status
Not open for further replies.

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,088
Reaction score
2,680
First Language
Greek
Primarily Uses
RMMZ
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.
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,074
Reaction score
7,983
First Language
German
Primarily Uses
RMMV
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.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,646
First Language
Czech
Primarily Uses
RMMV
This is not VXAce, the namespace is not $game_something, but $gameSomething.

So not $game_actors, but $gameActors.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,088
Reaction score
2,680
First Language
Greek
Primarily Uses
RMMZ
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:
# 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.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,088
Reaction score
2,680
First Language
Greek
Primarily Uses
RMMZ
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!
 
Last edited:

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,088
Reaction score
2,680
First Language
Greek
Primarily Uses
RMMZ

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

unnamed_image.jpg
SOMEONE'S SINGLE! HE DOES LIKE LONG WALKS IN THE IN THE SHADOWS AND THE SMELL OF DECAY. SADLY, HE HAS NO NUMBER TO NOTE OF BECAUSE HE HAS NO USE FOR A PHONE, BECUASE SUMMONING WORKS MUCH BETTER AND DOES NOT COME WITH AN ITEMISED BILL. REMEMBER TO TREAT HIM GOOD ON THE FIRST DATE!
I just found out that MZ regional price on Steam in my place is much cheaper than MV.
Our water started to work again, now i don't have to fill up our toilet with water again.
Finally able to return to work after months of lockdown. My poor feet are hurting :( I need to get used to working again haha

Forum statistics

Threads
108,880
Messages
1,040,255
Members
141,317
Latest member
BuddhaXD
Top