Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Monsieur OUXX on Fri 31/01/2014 12:21:29

Title: Extender function won't compile :-/
Post by: Monsieur OUXX on Fri 31/01/2014 12:21:29
This is probably a silly issue -- with some inverted lines of code, or a forgotten "import" or something.
I have a script (it's not the global script).

In the header:


import void AddItem_Safe(ListBox* this,  String item);


In the body:

void AddItem_Safe(ListBox* this,  String item)
{
  this.AddItem(item);
}

void WrapLine(ListBox* lstBox,  String desc)
{
  String buffer = "";
  lstBox.AddItem_Safe(buffer);
}



Then, when I compile :
Error: '.AddItem_Safe' is not a public member of 'ListBox'
(this error is rasied on the line with lstBox.AddItem_Safe(buffer);

I don't get it. What am I missing?
Title: Re: Extender function won't compile :-/
Post by: Crimson Wizard on Fri 31/01/2014 12:28:15
The proper syntax is:
void AddItem_Safe(ListBox this*,  String item) (* asteriks at different place)
Quotevoid AddItem_Safe(this ListBox*,  String item)
http://www.adventuregamestudio.co.uk/wiki/Extender_functions

What you wrote is a normal function which takes a list box object as first parameter.
Title: Re: Extender function won't compile :-/
Post by: Khris on Fri 31/01/2014 12:43:15
The proper syntax is
Code (ags) Select
void AddItem_Safe(this ListBox*,  String item)

Also, this is a pure RTFM fail. Just saying.
Title: Re: Extender function won't compile :-/
Post by: Crimson Wizard on Fri 31/01/2014 13:06:49
lol, right. Incorrectly edited the quote.
Title: Re: Extender function won't compile :-/
Post by: Monsieur OUXX on Fri 31/01/2014 14:45:04
Yep, pure RTFM. I told you it was silly!
The worse part is that I did read the manual page thouroughly, to check if I was putting the function in the right script, and if the import was OK.

Thanks guys.