Quote:
Originally Posted by scriptless
Interesting however I am a little confused. So TStaticVar includes object properties... but from where? Does this mean like the player properties if the TStaticVar is a player object, or if I create an object that has properties and then create a TStaticVar of the object?
|
When you create a TStaticVar it has no properties/attributes/etc. You can mold them however you wish and pass them around to functions.
e.g.
PHP Code:
function onCreated() {
temp.sword = createItem("Sword", "sword", 9999);
temp.shield = createItem("Shield", "shield", 100);
echoItemValue(temp.sword); // echos 100
echoItemValue(temp.shield); // echos 9999
echo(destroySword(temp.sword)); // echos sword destroyed
echo(destroySword(temp.shield)); // echos item is not sword
temp.shield.destroy();
}
function destroySword(item) {
if (item.itemtype == "sword") {
item.destroy();
return "sword destroyed";
} else {
return "item is not sword";
}
}
function echoItemValue(item) {
echo(item.value);
}
function createItem(itemname, itemtype, itemvalue, itemmods) {
temp.item = new TStaticVar();
temp.item.itemname = itemname;
temp.item.itemtype = itemtype;
temp.item.value = itemvalue;
temp.item.mods = itemmods;
return temp.item;
}