Midnight Kitty

Midnight
Veteran
Joined
Jun 18, 2013
Messages
129
Reaction score
14
First Language
English
Primarily Uses
RMMV
Code:
◆If:Script:(($gameActors.actor(1).isClass(5).id || $gameActors.actor(4).isClass(5).id || $gameActors.actor(5).isClass(5).id || $gameActors.actor(8).isClass(5).id || $gameActors.actor(9).isClass(5).id))
  ◆Jump to Label:Bypass
  ◆
:Else
  ◆Text:None, Transparent, Bottom
  :    :\N[1] Is not a thief. He cannot perform this
  :    :command.
  ◆If:Class of \N[1] is Thief
    ◆Jump to Label:Bypass
    ◆
  :End
  ◆Jump to Label:Break
  ◆
:End
It is an IF OR statement that should return true when any of the above actors are the thief class. Do these type of statements work in RPG maker?
I did try to get around it using the script
Code:
◆Script:if (($gameActors.actor(1).isClass(5).id || $gameActors.actor(4).isClass(5).id || $gameActors.actor(5).isClass(5).id || $gameActors.actor(8).isClass(5).id || $gameActors.actor(9).isClass(5).id)){
:      :$gameVariables.value(200); = 5;
:      :}
Then a conditonal branch to check the variable but it still through up the message that the actor was not a thief. Edit: I have a feeling it may be due to the isClass(5).id part but I am not sure.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
14,078
Reaction score
15,041
First Language
English
Primarily Uses
RMVXA
Or works fine in RPGMaker, so it is not that. Change it to isClass(4).id and see if it works, as class id's might be starting at 0 in the engine, and if that is the case you'll have to use 1 less than what you really want to access it.

Or try changing someone to class 6 in the database and see if that works now. In fact that might be faster.
 

Midnight Kitty

Midnight
Veteran
Joined
Jun 18, 2013
Messages
129
Reaction score
14
First Language
English
Primarily Uses
RMMV
I tried changing it to class 4 and it still returned false.
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
402
Reaction score
226
First Language
English
Primarily Uses
RMMV
Use this format instead, it should solve the issue.

Code:
$gameActors.actor(1).isClass($dataClasses[5])
 

Midnight Kitty

Midnight
Veteran
Joined
Jun 18, 2013
Messages
129
Reaction score
14
First Language
English
Primarily Uses
RMMV
That fixed it, seems to be working now.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
14,078
Reaction score
15,041
First Language
English
Primarily Uses
RMVXA
What you need to do is find a way to force the engine to print out the values of a script at certain points. In Ruby you can do that with msgbox_p( what you wish to print out), not sure about Javascript.

Now I did try your code in ACE and it says that code is NIL, which might be the problem. But maybe they changed it in Javascript to be a different reference.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,159
Reaction score
10,751
First Language
Czech
Primarily Uses
RMMV
@bgillisp In javascript it would be console.log (whatever)
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
402
Reaction score
226
First Language
English
Primarily Uses
RMMV
For troubleshooting I'll usually just use console.log() for checking values in MV.

EDIT: Ninja'd
 

Midnight Kitty

Midnight
Veteran
Joined
Jun 18, 2013
Messages
129
Reaction score
14
First Language
English
Primarily Uses
RMMV
I had the debug menu to check when the variable changed. Using
($dataClasses[5]) to check the class however fixed it. I added in an event to change the class of each actor at will and it worked each time.
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
670
Reaction score
390
First Language
English
Primarily Uses
RMMV
The Game_Actor.prototype.isClass method returns a boolean (true or false), which inherently do not have id properties. The actual method looks like this:
Code:
Game_Actor.prototype.isClass = function(gameClass) {
    return gameClass && this._classId === gameClass.id;
};
So when you pass in a class, you get back either the value "true" or the value "false". So, you were ultimately trying to do "true.id" and "false.id" in your original post, both of which return "undefined" - which JavaScript evaluates as false.

You could also reference the Actor's _classId property if you wanted:
Code:
$gameActors.actor(1)._classId === 5 || $gameActors.actor(4)._classId === 5

Are you ultimately just trying to see if there's a thief in the party, though? You could try the following if you're using RMMV 1.6 or greater:
Code:
$gameParty.members().find(member => member._classId === 5)

If you're using a version prior to 1.6, you could use:
Code:
$gameParty.members().filter(function(member) { return member._classId === 5; }).length
 

Midnight Kitty

Midnight
Veteran
Joined
Jun 18, 2013
Messages
129
Reaction score
14
First Language
English
Primarily Uses
RMMV
Thank you those do look like very nice extra solutions to the issue I was having.
 

Latest Profile Posts

Who wants to see me mock my brother's story? Brother story: thus he summoned a mighty twenty foot lizard. My Comment: Godzilla is attacking the city! As bad as these 4 are at shopping I wouldn't be surprised if Jun didn't proudly return with a chamber pot on her head. "Look at this helmet I got for 1,000 gold!"
Apparently I'm a grandpa now.

20220128_181216.jpg20220128_181227.jpg
Sales Goal of Learn RPG Maker MV at 64% now! :kaopride:
When I was in the hospital I did actually have a nurse that was funny, did all these extra nice things for me and said she liked me. So you know what that means. That will be the last time I'll hear from her.

Forum statistics

Threads
118,804
Messages
1,118,833
Members
155,986
Latest member
Aedryssian
Top