I have recently noticed if a member function is given the same name as a built-in function the compiler will report an "already defined" type of error. For example attempting to do the following will generate such an error ...
*** Module Header ****
struct MyStruct {
import static function Display(String text);
};
*** Module Script ****
static function MyStruct::Display(String text) {
Display(text);
}
*** Room Script ***
MyStruct.Display("Hello world!!");
I'm not 100% sure but I think this is only an issue with non-OOed functions. I don't know if this behavior is intentional or is the result of something leftover from before the OO version of the script language. I thought I would take the time to report it in case there is a list it should be on or something. If everything is as it should be then feel free to ignore this post. ;)
P.S. Yes, of course there are very obvious workarounds so I don't need any help with that :=. And yes there are times when it's desirable to wrap some additional functionality around standard functions.
I think it's somewhat of a known issue. There's no way to prevent it happening with built-in functions, like Display, but you can work around this (you said you don't need help with it, but just for reference ;)) with custom functions/properties...so long as the namespaced version is declared first.
AGS does have one specific example of this that I can think of. Since the Character structure is defined before the Room structure, Characters can have a 'Room' property.
So for example, this won't work:
int MyFunction() {
// do some fun stuff!!!
}
struct MyStruct {
import static int MyFunction(); // CRASHES GAME - 'MyFunction' ALREADY DEFINED!
};
Whereas this will work:
struct MyStruct {
import static int MyFunction();
};
int MyFunction() {
// do some fun stuff!!!
}
I wouldn't personally rate it high priority since the simplest workaround for the built in functions is of course just changing the name of your functions...:D...but if it's not difficult to fix I would certainly find it useful. ;)
Yeah this is a limitation of the script compiler, it's something that will be addressed whenever I get round to rewriting it.