Thread: TStaticVar()
View Single Post
  #11  
Old 03-23-2015, 10:41 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by scriptless View Post
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(itemnameitemtypeitemvalueitemmods) {
  
temp.item = new TStaticVar();
  
temp.item.itemname itemname;
  
temp.item.itemtype itemtype;
  
temp.item.value itemvalue;
  
temp.item.mods itemmods;
  return 
temp.item;

__________________
Quote:
Reply With Quote