I created this small script to run at the start of each battle to randomize what row(yanfly row_formations) the battler will be in depending on the class but the isClass function is throwing me a null error. I'm not really sure what the issue is. I was wondering if someone could help me understand the isClass function and the $dataClasses var.
Thanks in advance!
for (var i = 1; i < $gameParty.battleMembers().length; i++) {
var actor = $gameActors.actor(this._params);
var n = this._params[3];
if(actor.isClass($dataClasses[11])) {
var rndRow = Math.randomInt(4)+3;
actor.setRow(rndRow); }
}
Moderator note: @Atromes Instead of double posting your thread, you can ask from us to move it to its correct category. You can do this by using the report button on your own thread. Thank you.
I am not sure, since I never scratched the js parts of MV, but according to my knowledge, a method that is named isClass() should return a boolean value True or False, if whatever you put in the parentheses IS or IS NOT a class respectively.
$dataClasses[] seems not a variable, but an one dimension array to me.
An array is a set of variables of the same kind, set one after another.
You can refer to them by a pointer.
It probably contains the names of the Classes on the database, like Swordsman, Magician etc.
Thus $dataClasses[11] means probably the 11th Class name on the database.
And
$temp = $dataClasses[1]; // will assign the first class name that is set on the database to the variable $temp.
Again I am not sure, I got no idea, but the naming is so user friendly I couldn't resist to make some guesses that must be taken with a grain of salt.
Just checked the plugin and it seems I am probably right. If so, hopefully I helped you figure out some things.
The isClass method returns a Boolean value so it'll never be null unless it's been patched somehow to return null. I did a quick search though
YEP_RowFormation.js but I didn't find a reference to isClass. Does the actual error message say null or does it say undefined and you're calling that a null error? What is the exact error message?
Also, the $dataClasses array does contain the null value at element 0.
Thank you, guys... Greatly appreciate the feedback and help. This made me realize I still have a lot to learn in regards to the engine and syntax but have found some tutorials on the subject, thanks again.