So I'm pretty stuck on my Object-Based variables plugin and trying to search for some new perspectives. The Actor-based one is working, but for some reason Items are just being a ... PAIN! I'm looking through the Game_Item() class and it just stores or retrieves data based on a string and integer... the actual item objects are stored elsewhere.
What Are You Trying To Do?
Attempt to store 2 arrays onto each individual item picked up or initialized by each actor (or party inventory in the event of "picked up"). With Plugin Commands to add, remove, increase, reduce, or set a specific variable or switch by ID and value. Similar to the RMMV global switches and variables (default max is 5000 but can be changed in the plugin parameters)
_switches = [];
_variables = [];
What Have You Tried So Far?
I have initialized Game_Item() putting in the 2 arrays, and when I attempt to set a variable - use the following code as an example - then I get an TypeError: cannot set property "1" of undefined:
^ the plugin command is: "SetItemVariable armor 4 1 5"
What Seems To Be The Problem?
The item.. is not an object apparently. Or it is but the arrays are not being added to the item.
What Do You Want From Us?
I'm hoping the community can give me some fresh eyes/perspective. I'm still but an amateur programmer and to overcome this obstacle would be a great boon! Object-based switches and variables.. many many applications for that 😛 As I've mentioned, I already have actor-based variables and switches, and I'm sure the Party, Events, and Maps will be a lot easier as they're actual objects... but Items seems to be a different ballpark for some reason.
What Are You Trying To Do?
Attempt to store 2 arrays onto each individual item picked up or initialized by each actor (or party inventory in the event of "picked up"). With Plugin Commands to add, remove, increase, reduce, or set a specific variable or switch by ID and value. Similar to the RMMV global switches and variables (default max is 5000 but can be changed in the plugin parameters)
_switches = [];
_variables = [];
What Have You Tried So Far?
I have initialized Game_Item() putting in the 2 arrays, and when I attempt to set a variable - use the following code as an example - then I get an TypeError: cannot set property "1" of undefined:
Code:
LordV.cmdSetItemVariable = function(args) {
var actor = $gameParty.leader();
var type = args[0]; // item type (not used -yet-)
var typeID = Number(args[1]); // 4 Armor Slot (SlotID = 3)
var ID = Number(args[2]); // 1
var value = Number(args[3]); // 5
if (args[4] !== undefined) {
actor = $gameActors.actor(Number(args[4]));
}
var item = actor.equips()[typeID - 1];
// Now set the variable (and hope this works)
item._variables[ID] = value;
};
What Seems To Be The Problem?
The item.. is not an object apparently. Or it is but the arrays are not being added to the item.
What Do You Want From Us?
I'm hoping the community can give me some fresh eyes/perspective. I'm still but an amateur programmer and to overcome this obstacle would be a great boon! Object-based switches and variables.. many many applications for that 😛 As I've mentioned, I already have actor-based variables and switches, and I'm sure the Party, Events, and Maps will be a lot easier as they're actual objects... but Items seems to be a different ballpark for some reason.