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 01-25-2010, 02:39 AM
Grey Grey is offline
Classic Developer
Grey's Avatar
Join Date: Mar 2007
Location: Wales, UK
Posts: 134
Grey will become famous soon enough
Send a message via AIM to Grey
TStaticVar names

Just curious whether TStaticVar's are supposed to have a name when created on Clientside because I can't get them to display.

PHP Code:
//#CLIENTSIDE
...
temp.variable "Fish";
temp.testing= new TStaticVar("Name_"@variable);
testing.one"things";
testing.two "stuff";
player.chat testing;
... 
Will output nothing.

But serverside..

PHP Code:
...
temp.variable "Fish";
temp.testing= new TStaticVar("Name_"@variable);
testing.one"things";
testing.two "stuff";
echo(
testing);
... 
Outputs Name_Fish
Reply With Quote
  #2  
Old 01-25-2010, 02:56 AM
Immolate Immolate is offline
Indigo
Join Date: Dec 2009
Posts: 322
Immolate is on a distinguished road
Try using the 'name' variable to get it.
Reply With Quote
  #3  
Old 01-25-2010, 03:12 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Indeed.

echo(testing.name)
Reply With Quote
  #4  
Old 01-25-2010, 03:30 AM
Grey Grey is offline
Classic Developer
Grey's Avatar
Join Date: Mar 2007
Location: Wales, UK
Posts: 134
Grey will become famous soon enough
Send a message via AIM to Grey
Ahhh yep that did it. Thank you.
Reply With Quote
  #5  
Old 01-25-2010, 04:29 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
So what is TStaticVar()'s parameter used for?
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #6  
Old 01-25-2010, 05:06 AM
Grey Grey is offline
Classic Developer
Grey's Avatar
Join Date: Mar 2007
Location: Wales, UK
Posts: 134
Grey will become famous soon enough
Send a message via AIM to Grey
It makes it less than ideal to store objects in arrays as you can't use .index() and other built in functions (because an array of objects will all have the name ""). Would have to run through the array checking .name for each element.
Reply With Quote
  #7  
Old 01-25-2010, 05:38 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by LoneAngelIbesu View Post
So what is TStaticVar()'s parameter used for?
The name.

PHP Code:
new TStaticVar("MyObject");
MyObject.variable value
Just make sure you keep a reference to the object somewhere or the garbage collector will eat it.
__________________
Reply With Quote
  #8  
Old 01-25-2010, 07:23 AM
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 Grey View Post
It makes it less than ideal to store objects in arrays as you can't use .index() and other built in functions (because an array of objects will all have the name ""). Would have to run through the array checking .name for each element.
You can with player objects, so I'm not too sure how valid your statement actually is..

PHP Code:
echo(allplayers.index(findplayer("account"))); 
I've also done checks like..

PHP Code:
if (findplayer("account"in players) {
  
// stuff
}

if (
findweapon("-System"in player.weapons) {
  
// stuff

Edit: Further testing..

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
temp.= new TStaticVar();
  
temp.a.val 2;
  
temp.= new TStaticVar();
  
temp.b.val 1;
  
temp.= new TStaticVar();
  
temp.c.val 3;
  
temp.objs.add(temp.a);
  
temp.objs.add("LOL MESSING U UP"); // It doesn't :)
  
temp.objs.add(temp.b);
  
temp.objs.add(temp.c);
  echo(
temp.objs.index(temp.b));
  if (
temp.c in temp.objs) {
    echo(
"this also works..");
  }

Now we all benefit for not having to use loops to compare objects
__________________
Quote:

Last edited by fowlplay4; 01-25-2010 at 07:34 AM..
Reply With Quote
  #9  
Old 01-25-2010, 07:29 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Grey View Post
It makes it less than ideal to store objects in arrays as you can't use .index() and other built in functions (because an array of objects will all have the name ""). Would have to run through the array checking .name for each element.
Jerret is right. You can compare objects as objects, rather than comparing their names.

PHP Code:
temp.pl findPlayer("cbk1994");
temp.pl2 findPlayer("cbk1994");
temp.pl3 findPlayer("Grey");

echo(
pl == pl2); // 1
echo(pl == findPlayer("cbk1994")); // 1
echo(pl == pl3); // 0 
hence why you can also use "in" and functions like "index", as fowlplay said.
__________________
Reply With Quote
  #10  
Old 01-25-2010, 07:59 AM
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 LoneAngelIbesu View Post
So what is TStaticVar()'s parameter used for?
For stuff like this..

PHP Code:
//#CLIENTSIDE

function onCreated() {
  
// Object-based Design
  
new TStaticVar("Tree") {
    
this.30;
    
this.30;
  };
  
temp.= new Tree();
  
temp.a.+= 5;
  
temp.= new Tree();
  
temp.b.+= 2;
  
temp.= new Tree();
  
temp.c.-= 2;
  
temp.c.-= 4;
  
// Display Values
  
echo(temp.a.a SPC temp.a.b);  // 35 30
  
echo(temp.b.a SPC temp.b.b);  // 30 32
  
echo(temp.c.a SPC temp.c.b);  // 28 26

__________________
Quote:

Last edited by fowlplay4; 01-25-2010 at 08:12 AM..
Reply With Quote
  #11  
Old 01-25-2010, 09:04 PM
Grey Grey is offline
Classic Developer
Grey's Avatar
Join Date: Mar 2007
Location: Wales, UK
Posts: 134
Grey will become famous soon enough
Send a message via AIM to Grey
Quote:
Originally Posted by fowlplay4 View Post
Stuff
Appreciated you can do that if you have access to a var referencing the obj but what I was trying to do something along the lines of:

PHP Code:
//#CLIENTSIDE
function addToList(account) {
  
this.objs.add(new TStaticVar(@account));


function 
checkList() {
  return (
player.account in this.objs);

Which on the serverside would work. (If you changed checkList to be serverside friendly)

Was trying to see if I was doing it wrong somehow as if you output the array, rather than each of the objects having the name you'd assigned them, they all have blank names.

I'll just change the way its being handled but thanks guys
Reply With Quote
  #12  
Old 01-25-2010, 11:38 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
I'm pretty sure doing an equality check on objects implicitly casts them to their name and does a string comparison, which is pretty much worthless.
Reply With Quote
  #13  
Old 01-26-2010, 12:33 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
If all you're doing is storing the account names, then why would you need to use a TStaticVar(@account)?
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #14  
Old 01-26-2010, 05:02 AM
Grey Grey is offline
Classic Developer
Grey's Avatar
Join Date: Mar 2007
Location: Wales, UK
Posts: 134
Grey will become famous soon enough
Send a message via AIM to Grey
Quote:
Originally Posted by coreys View Post
If all you're doing is storing the account names, then why would you need to use a TStaticVar(@account)?
Why would you assume I'm only storing an account name if I'm trying to use a TStaticVar?

I was just using that as an example, each obj has stats and other info stored against it and are held on the server; info is passed to the client and a GUI is updated. User interaction is based off the current state of the objects and list of objects.

I don't know how great it is a method of doing it but I was hoping I could do checkList() or similiar to check the element actually existed, and control access to addition / removal of objects or data.

Last edited by Grey; 01-26-2010 at 05:25 AM..
Reply With Quote
  #15  
Old 01-26-2010, 08:22 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by WhiteDragon View Post
I'm pretty sure doing an equality check on objects implicitly casts them to their name and does a string comparison, which is pretty much worthless.
Incorrect.
__________________
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 09:58 PM.


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