Ok, from what I understand when making a module if you have a protected function within the struct that you have a public function only allows the public functions/members to be called from within the module.
Now here is my header
struct InvHandle{
import static function Click(InventoryItem *item);
//internals
protected import function Talk(InventoryItem *item);
};
and module
static function InvHandle::Click(InventoryItem *item){
if (mouse.Mode == eModeTalk) InvHandle.Talk(item);
}
protected function InvHandle::Talk(InventoryItem *item){
//talk stuff here
}
Yet when I try to save I get this:
---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was:
In: 'Inventory Handler'
Error (line 9): Cannot access protected member 'InvHandle::Talk'
Do you want to fix the script now? (Your game has not been saved).
---------------------------
Yes No
---------------------------
I thought since InvHandler.Click called InvHandler.Talk it would work since they are part of the same module, apparently this isn't the case...
What the hell did I miss?
That's a known issue regarding the access modifiers. I've begged for it to be changed, but have been ignored reasonably notified that it's low-priority. :P
Of course you're also trying to call a non-static function statically. So that's another issue.
You have a few different options at your disposal:
1) Make the functions publicly accessible. You can add a comment at the end of the line like "// $AUTOCOMPLETEIGNORE$" which will tell the autocomplete to ignore the line (i.e., the function).
2) Limit the functions to use with AGS 2.8 and use extender functions which will only be defined in the script, with no import in the header.
3) Make the regular functions non-static and access the protected functions via the this keyword.
Doh, didn't even think of the calling non static function statically, then again, with the error message it didn't even get that far to warn me of it.
Best bet is to just make Click non static and go from there.
Tanks monkey
The other thing you can do for having semi-protected things in structs in modules is to make an new type in the module script that extends the public module in the header.
Hmmm...I'd never considered that approach. Although the calling function would still have to be non-static to access the protected function.
Well I decided to just make them all static and save myself the trouble, the module is self contained now anyway as it has it's own on_mouse_click.
Anyways thanks for hte help... It's amazing how quickly you lose everything you know about scripting if you haven't done it in a few months.