![]() |
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:
But serverside.. PHP Code:
|
Try using the 'name' variable to get it.
|
Indeed.
echo(testing.name) |
Ahhh yep that did it. Thank you.
|
So what is TStaticVar()'s parameter used for?
|
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.
|
Quote:
PHP Code:
|
Quote:
PHP Code:
PHP Code:
PHP Code:
|
Quote:
PHP Code:
|
Quote:
PHP Code:
|
Quote:
PHP Code:
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 |
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.
|
If all you're doing is storing the account names, then why would you need to use a TStaticVar(@account)?
|
Quote:
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. |
Quote:
|
Quote:
PHP Code:
|
That doesn't exactly prove you are right.
My guess is behind the scenes TStaticVars and related objects have an id that it checks against with equality checks. |
Quote:
|
Quote:
I'm just saying that the name is likely what it is checking for a comparison, since it is a string that will always be there, and GS2 likes strings. There is no way to really know what the comparison is unless Stefan tells us, or someone writes a test case that is explicit enough. I certainly wouldn't make use of any of the code posted in this thread because I don't know exactly what it is doing and it would also be unclear and potentially misleading to anyone else who looks at the code. |
| All times are GMT +2. The time now is 08:38 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.