Script keeps returning false

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,522
Reaction score
14,255
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
399
Reaction score
221
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,522
Reaction score
14,255
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,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
@bgillisp In javascript it would be console.log (whatever)
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
399
Reaction score
221
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
640
Reaction score
353
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,859
Messages
1,017,030
Members
137,566
Latest member
Fl0shVS
Top