Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 03:01 PM.


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