![]() |
overloading function params?
I remember a while ago I was told that something such as the following would possess the same qualities as overloading functions (and I'm pretty sure it was from Stefan). However, now that I've found a place where I want to use it, I find that params aren't even loading into the function.
PHP Code:
PHP Code:
|
What is the player's chat being set to when the line:
player.chat = params.size(); is executed? |
There might be some misunderstanding about "params[]". It is always containing the parameters given to the script call, which means an event occured and is executing either the whole script (old script style) or a single event handler function, or you call a function of another object. When a gani script is executed then params[] will contain the gani parameters passed to setani() or setcharani().
So params[] is not containing the function parameters, that is only the case if you access it in the event handler function. Question is if it should be changed, it could make things more slow. Best solution in your case would be to accept two parameters - if the caller is only providing one parameter then the second parameter will be zero, which you could check. Or you do two different functions, for better readibility and so making it easier for other scripters to understand your code. Hmmm on the new Graal Bible (http://wiki.graal.net) we should eventually add a script FAQ were such things are added (once they get answered in this forum). |
Quote:
|
| All times are GMT +2. The time now is 08:24 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.