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 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
  #2  
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
  #3  
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
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 03:14 PM.


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