Quote:
Originally Posted by Stefan
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.
|
I suggested only functions in Control-NPC would be only ones qualifying as global, it would not be difficult at all to find out where they're declared if that is the case.
PHP Code:
// Script
function onCreated() {
addItem("sword", 1);
}
// Control-NPC
public function addItem(arch, count) {
player.mud.addItem(arch, count);
}
Simple enough.
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.