Midnight Kitty

Midnight
Regular
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,717
Reaction score
16,269
First Language
English
Primarily Uses
RMMZ
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
Regular
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
Regular
Joined
Nov 5, 2018
Messages
412
Reaction score
242
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
Regular
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,717
Reaction score
16,269
First Language
English
Primarily Uses
RMMZ
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
Regular
Joined
Mar 23, 2017
Messages
4,235
Reaction score
11,378
First Language
Czech
Primarily Uses
RMMV
@bgillisp In javascript it would be console.log (whatever)
 

Silva

Scoobityboo
Regular
Joined
Nov 5, 2018
Messages
412
Reaction score
242
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
Regular
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

Regular
Regular
Joined
Aug 4, 2012
Messages
681
Reaction score
420
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
Regular
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 Threads

Latest Posts

Latest Profile Posts

Steam is going to be forcing me to update my desktop OS for Mac. It's a good thing that my laptop is Windows otherwise some of my work and a lot of game save files for 32-bit games would become unusable for a while.
Last day in Florida and then we head home. It was a fun, relaxing trip with just the wifey poo. Still managed to make some progress on my Game Jam project though.
Never fully realized that I had this account, nice start
On NEOLITHIC's 2nd Steam Anniversary, we walk on the path of Gabe's blessing. :p
GabeNFaithEN.jpg
What might the petitdevil be thinking right now?
1702054100193.png
And did you leave all your love and comments on the advent calendars today already?

Forum statistics

Threads
136,843
Messages
1,270,674
Members
180,609
Latest member
shiranui_bzw
Top