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
13,967
Reaction score
14,818
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
225
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
13,967
Reaction score
14,818
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,158
Reaction score
10,730
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
225
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
388
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 Threads

Latest Posts

Latest Profile Posts

I'm new to rpgmaker mv, link me some good stuff to learn.
Finally, I have graduated from college and now I can put a lot more work into my game, after having not worked on it for the better part of a year.
post so i can change my profile picture ^^
Creating Some art for a fighter game.

Finally was able to record the rest of the game demo! I added some edits here and there, this is why it takes me so long to do stuff cuz I find a problem and have to fix it asap. x.x
Game: https://dj990j.itch.io/region-of-mythos

Forum statistics

Threads
117,063
Messages
1,104,221
Members
153,028
Latest member
Bbigdadddi
Top