Alright so with the release of the actor-based switches and variables plugin I made, I was thinking of expanding it...
- Items
- Maps
- Events
- Troops
However on the first of the list (items) I'm already running into a snag. For most of the actor-based ones I was going off of the Game_Actors() object (( Game_Actor.prototype.setActorVariable = function(ID, value) {} )) and it was pretty straight forward, however I tried to make the functions more broad. (see partial code below)
-- EDIT --
I do seem to notice the problem lies with the initialization.... the _switches and _variables arrays are not being assigned to the items themselves, perhaps?
So I try to setup a simple plugin command "SetArmorVariable 4 1 5" (4 = armor ID; 1 = Variable ID; 5 = Value).
Inside the plugin, it gets the armor item:
The item registers normally, I can retrieve its details, it's valid, etc, but it won't pass onto the setVariable function. Any ideas?
( see attached screen for current errors at the time of this posting )
=== For those familiar with Neverwinter Nights, or possibly some other toolsets for games, that you can place variables on objects (creatures, placeables, items, etc.) and I'm trying to replicate the same thing here 😛
- Items
- Maps
- Events
- Troops
However on the first of the list (items) I'm already running into a snag. For most of the actor-based ones I was going off of the Game_Actors() object (( Game_Actor.prototype.setActorVariable = function(ID, value) {} )) and it was pretty straight forward, however I tried to make the functions more broad. (see partial code below)
-- EDIT --
I do seem to notice the problem lies with the initialization.... the _switches and _variables arrays are not being assigned to the items themselves, perhaps?
Code:
var LordV = LordV || {};
// ======================================
// * Naturally we setup the Game_Item alias, yes?
// ======================================
LordV.Game_Item_initialize = Game_Item.prototype.initialize;
Game_Item.prototype.initialize = function(item) {
LordV.Game_Item_initialize.call(this, item);
this._switches = [];
this._variables = [];
}
LordV.setVariable = function(object, variableId, value) {
if (variableId > 0 && variableId <= LordV.maxVariables) { // maxVariables = plugin parameter
if (typeof value === 'number') {
value = Math.floor(value);
}
object._variables[variableId] = value;
}
}
So I try to setup a simple plugin command "SetArmorVariable 4 1 5" (4 = armor ID; 1 = Variable ID; 5 = Value).
Inside the plugin, it gets the armor item:
Code:
LordV.cmdSetArmorVariable = function(args) {
var actor = $gameParty.leader();
var itemId = Number(args[1]);
var ID = Number(args[2]);
var value = Number(args[3]);
var item = actor.equips()[itemId - 1];
this.setVariable(item, ID, value);
}
The item registers normally, I can retrieve its details, it's valid, etc, but it won't pass onto the setVariable function. Any ideas?
( see attached screen for current errors at the time of this posting )
=== For those familiar with Neverwinter Nights, or possibly some other toolsets for games, that you can place variables on objects (creatures, placeables, items, etc.) and I'm trying to replicate the same thing here 😛