Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-23-2015, 08:22 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
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?
Reply With Quote
  #2  
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
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.