Hello. I started working with RPG Maker MV recently and I began working on creating a plug-in and I encountered a strange error that I don't know how to resolve.
The issue is that I created a function to check the noteboxes for a notetag that is supposed to be able to be called by any class. The function definition is:
checkNotes = function(notes, tag, args, i, g, m) {
if (args == null) {
var regexp = "<" + String(tag) + ">";
} else if (args == "num") {
var regexp = "<" + String(tag) + ": (\d+)>";
} else if (args == "plusMinus") {
var regexp = "<" + String(tag) + ": (+|-)(\d+)>";
} else if (args == "num%") {
var regexp = "<" + String(tag) + ": (\d+)%>";
} else if (args == "plusMinus%") {
var regexp = "<" + String(tag) + ": (+|-)(\d+)%>";
} else if (args == "string") {
var regexp = "<" + String(tag) + ": (.+)>";
} else if (args == "statNum") {
var regexp = "<" + String(tag) + "(\w+): (\d+)>";
} else if (args == "statPlusMinus") {
var regexp = "<" + String(tag) + "(\w+): (+|-)(\d+)>";
} else if (args == "statNum%") {
var regexp = "<" + String(tag) + "(\w+): (\d+)%>";
} else if (args == "statPlusMinus%") {
var regexp = "<" + String(tag) + "(\w+): (+|-)(\d+)%>";
} else if (args == "numArray") {
var regexp = "<" + String(tag) + ": (\d{1})>";
} else
var regexp = "<" + String(tag) + String(args) + ">";
};
if (i) {
regexp += "i";
};
if (m) {
regexp += "m";
};
if (g) {
regexp += "g";
};
var vals = notes.match(RegExp(regexp));
return vals
};
Then later I go to use that function in the following function:
Game_Enemy.prototype.level = function() {
//return 1
checkNotes(this.enemy.note, "level", "num", true);
return Number($1);
};
But when the function is called upon, I get an error saying:
This is despite the fact that I had already defined the method above in the same plug-in. What did I do wrong? Everything seems in order.
The issue is that I created a function to check the noteboxes for a notetag that is supposed to be able to be called by any class. The function definition is:
checkNotes = function(notes, tag, args, i, g, m) {
if (args == null) {
var regexp = "<" + String(tag) + ">";
} else if (args == "num") {
var regexp = "<" + String(tag) + ": (\d+)>";
} else if (args == "plusMinus") {
var regexp = "<" + String(tag) + ": (+|-)(\d+)>";
} else if (args == "num%") {
var regexp = "<" + String(tag) + ": (\d+)%>";
} else if (args == "plusMinus%") {
var regexp = "<" + String(tag) + ": (+|-)(\d+)%>";
} else if (args == "string") {
var regexp = "<" + String(tag) + ": (.+)>";
} else if (args == "statNum") {
var regexp = "<" + String(tag) + "(\w+): (\d+)>";
} else if (args == "statPlusMinus") {
var regexp = "<" + String(tag) + "(\w+): (+|-)(\d+)>";
} else if (args == "statNum%") {
var regexp = "<" + String(tag) + "(\w+): (\d+)%>";
} else if (args == "statPlusMinus%") {
var regexp = "<" + String(tag) + "(\w+): (+|-)(\d+)%>";
} else if (args == "numArray") {
var regexp = "<" + String(tag) + ": (\d{1})>";
} else
var regexp = "<" + String(tag) + String(args) + ">";
};
if (i) {
regexp += "i";
};
if (m) {
regexp += "m";
};
if (g) {
regexp += "g";
};
var vals = notes.match(RegExp(regexp));
return vals
};
Then later I go to use that function in the following function:
Game_Enemy.prototype.level = function() {
//return 1
checkNotes(this.enemy.note, "level", "num", true);
return Number($1);
};
But when the function is called upon, I get an error saying:
Code:
ReferenceError: checkNotes is not defined
at Game_Enemy.level (NCE_BasicModule.js:133)
at Game_Enemy.name (NCE_BasicModule.js:138)
at Window_BattleEnemy.drawItem (rpg_windows.js:5626)
at Window_BattleEnemy.Window_Selectable.drawAllItems (rpg_windows.js:1250)
at Window_BattleEnemy.Window_Selectable.refresh (rpg_windows.js:1277)
at Window_BattleEnemy.refresh (rpg_windows.js:5644)
at Window_BattleEnemy.initialize (rpg_windows.js:5591)
at new Window_BattleEnemy (rpg_windows.js:5580)
at Scene_Battle.createEnemyWindow (rpg_scenes.js:2223)
at Scene_Battle.createAllWindows (rpg_scenes.js:2156)
This is despite the fact that I had already defined the method above in the same plug-in. What did I do wrong? Everything seems in order.