![]() |
Global Functions
Why haven't they been implemented yet? We even have function objects now but no global functions yet, its not that hard to do I'm sure. Don't like using classes for things that should be global anyways.
|
I am not sure how you magically expect global functions to work internally in the script engine.
Just use classes. :/ They aren't that inconvenient. |
Quote:
Quote:
|
Global functions are techincally possible, but they make programming actually much harder. It is making it even harder to find where the function is declared. We already have global variables, and we should not repeat that mess with global functions. It is much cleaner to put the functions in an npc and call NPCName.function(), or put it in a class.
|
Quote:
PHP Code:
I'm not suggesting global functions be declared the same way that global variables are (since that would be a horror as you're saying), just that when the Control-NPC is compiled its functions added to the global list or something. So basically, for the function lookup, if there is no prefix it would look at: Local Object (this.) -> Control-NPC -> Static Globals. |
could be nice
|
Why not simply use MyFunctionsNPC.function() ?
|
Quote:
It could be nice with global functions that would make it so you couldn't make more functions with the same name, for example when you make another onCreated() event or make two functions with the same name, it will cause an error PHP Code:
|
Quote:
For the classes, rather than having to join small utility classes to everything that uses it you can just join it to the Control-NPC and then everything can use it, including the random LAT with little knowledge of scripting. Having globals puts everything on the same plate and would make it easier for people unfamiliar with the system. I don't think its asking much to make public functions in the Control-NPC global (and those with a global_ prefix in the function name only?). Since they would only work in the Control-NPC it would the massive chaos of someone not knowing where the global function is declared. |
Bump
I would appreciate a response. |
Still seeing it as bad coding style.
|
Quote:
I don't see how its bad coding style to have a single additional location in the function-lookup process. Local Object -> Control-NPC -> Static Globals There is nothing confusing about that. It puts all the globals in one bag so you can't miss them. |
I mean, they would only be placed in the Control Npc so that it won't be a hard to find the functions when necessary.
I completely agree with this as it would be a nice addition to servers period |
I don't think Stefan should honestly have to go through that just to save yourself from having to join a class or putting a weapon name in front of the function. (i.e. "FunctionsWeapon".doThingy())
|
Quote:
|
All times are GMT +2. The time now is 03:27 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.