Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: toast eating fiend on Wed 15/02/2012 14:35:57

Title: How to import global functions for use in events in the properties window
Post by: toast eating fiend on Wed 15/02/2012 14:35:57
My script throws this error during runtime:
Error: prepare_script: error -18 (no such function in script) trying to run 'globalfunction' (Room 1)
[ACI version 3.12.1115]

I've defined this global function in GlobalScript.asc, and imported it in GlobalScript.ash.

When I try to call this function from within the room script, it works fine, but when I call it as an Event from the Properties Window, it gives me the above error.

Is there any way to import global functions for use in events?
Title: Re: How to import global functions for use in events in the properties window
Post by: Gudforby on Thu 16/02/2012 08:41:11
I don't know if that's possible.

But a quick workaround is to create a new function in the room script, and run that from the event window.
In that function you can run your 'globalfunction'.

Works like shit!
Title: Re: How to import global functions for use in events in the properties window
Post by: toast eating fiend on Thu 16/02/2012 13:39:32
I was rather hoping not to have to include an extra function in every room, but at least this way I can still update the function relatively easily. So I guess the header doesn't get imported into whatever script the events use? Thanks for your answer!
Title: Re: How to import global functions for use in events in the properties window
Post by: Khris on Thu 16/02/2012 21:38:54
The header gets imported, but it seems like a room event can only be linked to a function that's defined in the room script.
Global events like inventory item or character interactions should be able to call your function fine.
Title: Re: How to import global functions for use in events in the properties window
Post by: toast eating fiend on Fri 17/02/2012 05:51:00
Good to know, thanks for the info!