View Single Post
  #15  
Old 03-31-2012, 06:47 PM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Quote:
Originally Posted by Skyld View Post
PHP Code:
function onCreated()
{
  
temp.obj = new TStaticVar("SomeObject");
  
  
temp.one = new SomeObject();
  
temp.two = new SomeObject();
  
  
temp.one.asdf "hi";
  
temp.two.asdf "foo";
  
  echo(
format("Object one is '%s'"temp.one));
  echo(
format("Object two is '%s'"temp.two));
  echo(
format("Object keys: '%s', '%s'"temp.one.asdftemp.two.asdf));
  
  
// Compare the objects as objects
  
if (temp.one == temp.two)
    echo(
"Objects are the same");
  else
    echo(
"Objects are different");
  
  
// Compare the objects after being coerced to strings
  
if (@temp.one == @temp.two)
    echo(
"Object names are equal");
  else
    echo(
"Object names are different");  

Output:
NPC Code:
Object one is 'SomeObject'
Object two is 'SomeObject'
Object keys: 'hi', 'foo'
Objects are different
Object names are equal


When the objects are coerced into strings, you get the object names only typically. In this example, it results in two objects appearing to be the same (because their object names are the same) even though we have just proven them to be different.

This is something you MUST be aware of when coercing objects into strings in GScript. It doesn't always work how you expect.
Sorry, I know you are trying to help, but I'm confused as to what any of that means..

Can you do it in layman's terms and possibly actually use levels?
Also, why are levels objects and not only strings?
I thought levels were only names of a textfiles converted to .nw..
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



Reply With Quote