Looking at the code I found several times the use of a variable / object in as a condition such as
Game_Item.prototype.setObject = function(item) {
if (DataManager.isSkill(item)) {
this._dataClass = 'skill';
} else if (DataManager.isItem(item)) {
this._dataClass = 'item';
} else if (DataManager.isWeapon(item)) {
this._dataClass = 'weapon';
} else if (DataManager.isArmor(item)) {
this._dataClass = 'armor';
} else {
this._dataClass = '';
}
this._itemId = item ? item.id : 0;
The last line here or:
Game_Actor.prototype.changeEquip = function(slotId, item) {
if (this.tradeItemWithParty(item, this.equips()[slotId]) &&
(!item || this.equipSlots()[slotId] === item.etypeId)) {
this._equips[slotId].setObject(item);
this.refresh();
}
};
Third line. How exactly works this? The condition equals to true if the object is not null or is a special feature of Game_Item class? Also, what is the purpose in this last example using "!item"? Because I can't really get the condition...
Game_Item.prototype.setObject = function(item) {
if (DataManager.isSkill(item)) {
this._dataClass = 'skill';
} else if (DataManager.isItem(item)) {
this._dataClass = 'item';
} else if (DataManager.isWeapon(item)) {
this._dataClass = 'weapon';
} else if (DataManager.isArmor(item)) {
this._dataClass = 'armor';
} else {
this._dataClass = '';
}
this._itemId = item ? item.id : 0;
The last line here or:
Game_Actor.prototype.changeEquip = function(slotId, item) {
if (this.tradeItemWithParty(item, this.equips()[slotId]) &&
(!item || this.equipSlots()[slotId] === item.etypeId)) {
this._equips[slotId].setObject(item);
this.refresh();
}
};
Third line. How exactly works this? The condition equals to true if the object is not null or is a special feature of Game_Item class? Also, what is the purpose in this last example using "!item"? Because I can't really get the condition...