Hello, good evening, I have been trying to create a text command in "rpg_windows" that allows me to read Arrays within variables.
The idea of this was having to avoid putting all the Armor and Item numbers into a variable manually, since before I did the following: "$gameVariables.setValue(5, $gameParty.armors()]") and then it generated a text message with a scriptcall, because it could not directly call the icon of the object in question inside the text box with "\I[\V[5,1]]".
So inside the "rpg_windows" Plugin, in "convertEscapeCharacters", I added the following code:
So when writing "\W[5,0]" it returns the array loaded in the Variable, it is worth clarifying that with this, I also attach the ".iconIndex" to the end of line 2, with that, I can use this command within the text window.
What is the problem? Since there is no established Array limit, if you write a number that is not loaded in the Player's inventory, you will get a "null" or "Undefined".
How could I avoid this?
The idea of this was having to avoid putting all the Armor and Item numbers into a variable manually, since before I did the following: "$gameVariables.setValue(5, $gameParty.armors()]") and then it generated a text message with a scriptcall, because it could not directly call the icon of the object in question inside the text box with "\I[\V[5,1]]".
So inside the "rpg_windows" Plugin, in "convertEscapeCharacters", I added the following code:
JavaScript:
text = text.replace(/\x1bW\[(\d+),(\d+)\]/gi, function() {
return $gameVariables.value(parseInt(arguments[1]))[parseInt(arguments[2])].iconIndex;//MOD
}.bind(this));
So when writing "\W[5,0]" it returns the array loaded in the Variable, it is worth clarifying that with this, I also attach the ".iconIndex" to the end of line 2, with that, I can use this command within the text window.
What is the problem? Since there is no established Array limit, if you write a number that is not loaded in the Player's inventory, you will get a "null" or "Undefined".
How could I avoid this?