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:
- I replaced Somebody by character, who is actually stored as Somebody- worked
- I was tring to find some forgotten script lines in global script, that could break that- nothing
- I placed all of this script from separated script into the global script- now, the game works fine, but I need this in separated script
Yes, it looks like the problem is in point number two, but it cannot! I believe there is a simple explanation of this. :-\
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);
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.
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... :'(