Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Lufia on Fri 01/10/2010 07:49:59

Title: Manipulating arrays / import-export
Post by: Lufia on Fri 01/10/2010 07:49:59
So, I can't find a section in the manual devoted to arrays. How would I go about appending a value at the end of an array? And clearing the entire array? Upon creating an array, is it filled with null elements, or some default value depending on the type I set? Can you compare two arrays? Is there a way to get the size of an array?

I also need a refresher on import / export statements and using script headers.
Say I write some function in a script, and I want to use it in another one. I gathered that I should write my import statement in the header of the script where the function is defined. But am I not exporting said function from that script, rather than importing it? And what exeternal scripts are able to access my newly "imported" function, exactly? All of them?
As for importing / exporting variables, I get that I should write my export statement somewhere below its declaration in the body of the script. Where do I write the import? In the header as well?
And lastly, if I define a custom struct in the header of a script, am I able to use it wherever I want?

If this stuff is answered somewhere in the help file, direct me to the right section. Thanks.
Title: Re: Manipulating arrays / import-export
Post by: Khris on Fri 01/10/2010 16:46:18
Array support is limited. You can't dynamically append an element, clearing them has to be done manually.
Just like standard variables, arrays hold 0/false/null when they're declared.
You can compare two arrays but only manually, there's no built-in functionality.
Other than storing the size when creating it, you can't get an array's length.

Functions don't need to be exported.
To use variables/functions in other scripts, import their declaration line in the header. The reason is that a script's header is put above every other script further down the list.
Thus if script A needs to use a function defined in script B, script A needs to be below script B in the script tree.

Similarly, if you define structs in a header, make sure it's above every other script that's going to use it.

As a rule of thumb, the more generally or globally a variable/functions is going to be used, the higher it goes in the script list.
Title: Re: Manipulating arrays / import-export
Post by: Lufia on Fri 01/10/2010 20:54:40
Quote from: Khris on Fri 01/10/2010 16:46:18
Array support is limited. You can't dynamically append an element, clearing them has to be done manually.
Just like standard variables, arrays hold 0/false/null when they're declared.
You can compare two arrays but only manually, there's no built-in functionality.
Other than storing the size when creating it, you can't get an array's length.
Well, curses. That really limits the use of dynamic arrays, doesn't it?

Unrelated question: is there any way to toggle between full screen and window mode during the game? I could only find the Windowed property in relation to this, which is read-only.
Title: Re: Manipulating arrays / import-export
Post by: Gilbert on Sun 03/10/2010 13:58:19
Quote from: Lufia on Fri 01/10/2010 20:54:40
Unrelated question: is there any way to toggle between full screen and window mode during the game? I could only find the Windowed property in relation to this, which is read-only.
No.
Title: Re: Manipulating arrays / import-export
Post by: GarageGothic on Sun 03/10/2010 14:03:32
Quote from: Gilbet V7000a on Sun 03/10/2010 13:58:19
Quote from: Lufia on Fri 01/10/2010 20:54:40
Unrelated question: is there any way to toggle between full screen and window mode during the game? I could only find the Windowed property in relation to this, which is read-only.
No.

Though someone (SSH?) wrote a plugin that allowed changing those options in the .cfg file and restarted the game with those settings.

Edit: Not a plugin, a VBScript, but here it is (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37291.0).