Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Superman95 on Sun 23/11/2003 00:53:33

Title: Script Arrays
Post by: Superman95 on Sun 23/11/2003 00:53:33
Is it possible to create an Array in the script system.  I realize the "character" is an array, but it seems to be a special object in the system.  If I can define arrays, what's the syntax?
Title: Re:Script Arrays
Post by: Scorpiorus on Sun 23/11/2003 01:48:22
Yep, you can declare an array this way:

int array[10];

declares array of 10 integers (Note: indexes go 0 through 9, so 9 is the last index)

writing data:

array[5] = 3;

reading:

int value = array[5];


PS. It's unofficial feature though

~Cheers
Title: Re:Script Arrays
Post by: Superman95 on Sun 23/11/2003 02:05:12
Thanks.

I'm beginning to think there's lots of stuff the script can do that's not documented.  Like #define.

Wonder if I can #include "filename" to include an external script file?


Hey, Chris,
That would be a cool feature.  Imagine: you write a script that has a lot of basic general functionality, then you could just copy the file into anyother project, use and #include statement, and reuse the code.
Title: Re:Script Arrays
Post by: Scorpiorus on Sun 23/11/2003 11:56:05
Would be very handy indeed. Something like this is in his to-do list I believe.

~Cheers
Title: Re:Script Arrays
Post by: Ishmael on Sun 23/11/2003 13:53:46
I already suggested the #include, I just couldn't find the goddam thead, and Chris reacted a bit negatively, if I remeber right... but as I can't find the thead, I cannot say for sure...
Title: Re:Script Arrays
Post by: Scorpiorus on Sun 23/11/2003 14:44:39
Quote from: TK on Sun 23/11/2003 13:53:46
I already suggested the #include, I just couldn't find the goddam thead, and Chris reacted a bit negatively, if I remeber right... but as I can't find the thead, I cannot say for sure...
I think the #include thing itself is rather easy to implement, but as I remember what Chris was referring to is a problem when you have to watch you haven't identical function names or such thing as forward referencing (that is the function is called before being defined) as AGS can't handle that at the moment.

I realy hope we'll se some sort of a modul support system in 2.6xx series.

~Cheers
Title: Re:Script Arrays
Post by: Ishmael on Sun 23/11/2003 20:40:05
Yeah... It would theoretically (sp?) be like, the scripts are included from the files, then, the whole script would be run through... but how to make it?
Title: Re:Script Arrays
Post by: Scorpiorus on Sun 23/11/2003 21:15:37
Yep, it would be similar to the script header but you can include the file withing the whole script. So, if compiling error occures the editor should open the right file on the right line instead of telling that there is a error in the global script line number 978 whereas the global script itself is only about 100 lines of code. :P
Title: Re:Script Arrays
Post by: Ishmael on Mon 24/11/2003 06:20:01
Yeah... "Error: blah blah blah in external script file "blah.txt" line blah." etc.