Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Bug: The max loop limit can no longer be avoided serverside with a sleep. (https://forums.graalonline.com/forums/showthread.php?t=134265678)

fowlplay4 03-31-2012 07:05 PM

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.

Devil_Lord2 03-31-2012 08:27 PM

Quote:

Originally Posted by fowlplay4 (Post 1690565)
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?

Skyld 03-31-2012 09:02 PM

Quote:

Originally Posted by Devil_Lord2 (Post 1690581)
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).

ffcmike 03-31-2012 10:03 PM

Quote:

Originally Posted by Devil_Lord2 (Post 1690581)
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'.

Devil_Lord2 03-31-2012 10:24 PM

Quote:

Originally Posted by Skyld (Post 1690585)
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 (Post 1690599)
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?

Skyld 03-31-2012 10:35 PM

Quote:

Originally Posted by Devil_Lord2 (Post 1690601)
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".

Devil_Lord2 03-31-2012 11:27 PM

Quote:

Originally Posted by Skyld (Post 1690605)
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.

Starfire2001 05-03-2012 05:50 PM

Quote:

Originally Posted by xXziroXx (Post 1690141)
Bump, also seems to happen clientside.

Bumping this as I'm also running into this problem clientside.


All times are GMT +2. The time now is 03:34 AM.

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