declaration question

Started by FortressCaulfield, Wed 22/05/2024 00:17:41

Previous topic - Next topic

FortressCaulfield

Maybe I'm just dumb but I can't figure out how to declare functions that are defined in global such that room scripts can call them.

IE if I have a bool function is_toast(int itemnumber) what do I need to do to be able to use it in room scripts without the room script throwing up an error because it doesnt know what is_toast is?
"I can hear you! My ears do more than excrete toxic mucus, you know!"

Crimson Wizard

This is explained in this article in the manual:
https://adventuregamestudio.github.io/ags-manual/ImportingFunctionsAndVariables.html

Normally you should have in the global header:
Code: ags
import bool is_toast(int itemnumber);

FortressCaulfield

Quote from: Crimson Wizard on Wed 22/05/2024 00:46:54This is explained in this article in the manual:
https://adventuregamestudio.github.io/ags-manual/ImportingFunctionsAndVariables.html

Normally you should have in the global header:
Code: ags
import bool is_toast(int itemnumber);

Thanks, I did find it eventually. Problem with the manual is that it's really only helpful if you already know what the things are called. My old C using ass was looking for extern.

So if I put import in global header I don't have to do it in each room script? That's what I have been doing.
"I can hear you! My ears do more than excrete toxic mucus, you know!"

Khris

Quote from: FortressCaulfield on Wed 22/05/2024 14:23:38So if I put import in global header I don't have to do it in each room script? That's what I have been doing.
Yes, because the global headers are put on top of the room scripts at compile time.

SMF spam blocked by CleanTalk