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
  #16  
Old 03-31-2012, 07:05 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
Levels are instances of TServerLevel objects.

Level files are parsed/processed and loaded into memory as TServerLevel objects.

player.level refers to the TServerLevel object the player is currently in.
__________________
Quote:
Reply With Quote
  #17  
Old 03-31-2012, 08:27 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 fowlplay4 View Post
Levels are instances of TServerLevel objects.

Level files are parsed/processed and loaded into memory as TServerLevel objects.

player.level refers to the TServerLevel object the player is currently in.
D: So why is .name added to it?
Does it make a difference for levels?
__________________

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



Reply With Quote
  #18  
Old 03-31-2012, 09:02 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Devil_Lord2 View Post
D: So why is .name added to it?
Does it make a difference for levels?
Well, player.level is an object which represents the level, so player.level.name gets the name attribute of the level object. The name attribute is already a string, so it does not result in the object being coerced (the example I posted above shows why relying on object-to-string coercion is a really bad idea).
__________________
Skyld
Reply With Quote
  #19  
Old 03-31-2012, 10:03 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Devil_Lord2 View Post
D: So why is .name added to it?
Does it make a difference for levels?
Perhaps a good example would be the 'player' object. Within your script you're using player.account, 'player' being an object which can have variables written to and functions invoked on it, '.account' being a string/text value. If you can recognise that it is correct to use player.account instead of just 'player', you should also recognise it as correct to use level.name instead of just 'level'.
Reply With Quote
  #20  
Old 03-31-2012, 10:24 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
Well, player.level is an object which represents the level, so player.level.name gets the name attribute of the level object. The name attribute is already a string, so it does not result in the object being coerced (the example I posted above shows why relying on object-to-string coercion is a really bad idea).
So ".level" isn't suppose to be a string for level, or it needs to convert it to a string while if I just add ".level.name" it saves it stress from doing it itself?


Quote:
Originally Posted by ffcmike View Post
Perhaps a good example would be the 'player' object. Within your script you're using player.account, 'player' being an object which can have variables written to and functions invoked on it, '.account' being a string/text value. If you can recognise that it is correct to use player.account instead of just 'player', you should also recognise it as correct to use level.name instead of just 'level'.
My problem is that if I don't use .account it will not work.. for whatever I might be trying to do, yet on level it does.. which is why I don't understand...

It is like some people saying why not keep some scripts GS1 for some parts if those parts still work and don't necessarily need to be fixed. I think that is a good metaphor?
__________________

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



Reply With Quote
  #21  
Old 03-31-2012, 10:35 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Devil_Lord2 View Post
So ".level" isn't suppose to be a string for level, or it needs to convert it to a string while if I just add ".level.name" it saves it stress from doing it itself?
In crude terms, yes. You should not expect that coercing an object to a string actually does what you think, so don't rely on it just because it "sometimes works".
__________________
Skyld
Reply With Quote
  #22  
Old 03-31-2012, 11:27 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
In crude terms, yes. You should not expect that coercing an object to a string actually does what you think, so don't rely on it just because it "sometimes works".
Well, with all that stated, I'll definitely try to remember to correct these and future level.name checks. :]

Thank you both, much appreciated.
__________________

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



Reply With Quote
  #23  
Old 05-03-2012, 05:50 PM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
Quote:
Originally Posted by xXziroXx View Post
Bump, also seems to happen clientside.
Bumping this as I'm also running into this problem clientside.
__________________
-Ph8
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 07:36 PM.


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