Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: .M.M. on Mon 28/07/2008 21:39:12

Title: Difference between automaticaly and manualy created sripts?
Post by: .M.M. on Mon 28/07/2008 21:39:12
The question is: what exactly is different between Global script and manually created separated script (also, I am not talking about things like dialog request  etc.)? My problem is this: I created separated sript and placed here some script with own functions for simplification of global script. And yes, i placed there everything, from character variables to static functions. My game loaded perfectly, but when AGS started to work with my script, it shutted down ant announced me error "unresolved import of variable"- it is in line Somebody.LoseInventory(iLosedInventroy);.I tried this:
Title: Re: Difference between automaticaly and manualy created sripts?
Post by: magintz on Tue 29/07/2008 00:38:47
You need to make it available to all the rooms rather than just the global scripts by importing it via the script header.

For example:

If, in your Global Script (GlobalScript.asc), you have created a function


function sayHello(String response)
{
  player.Say(response);
}


Then in the Global scripts header (GlobalScript.ash) you need to insert the following to make it accessible to all rooms


import function sayHello(String response);
Title: Re: Difference between automaticaly and manualy created sripts?
Post by: monkey0506 on Tue 29/07/2008 07:23:02
Actually the same rules and principles apply to all scripts, so that doesn't really answer the question.

The reason for the global script is to provide AGS one place to look for all of your global event handler functions for things like GUIs and Characters. For Hotspots and Objects the handlers go in the room script. So say you have an event handler function for talking to a Character cMerchant named cMerchant_Talkto. AGS would then expect to find this function in the global script. It cannot appear in any other script.

The reason for "manually created scripts" is to keep the global script free of other scripts, to prevent clutter. Also, it makes the scripts portable by exporting them as modules.
Title: Re: Difference between automaticaly and manualy created sripts?
Post by: .M.M. on Tue 29/07/2008 16:02:29
magintz: thanks for help, but I forgot to say I have done this too.
Now, I will try to copy my script to new created script part, just for sureness.
And also, yes you´re right monkey, the main problem is that I need it as module: my problem is strange, because in older version, I had no problems with that variable... :'(