Page 1 of 1

Array: This is like...

PostPosted: Sun Apr 05, 2009 4:54 pm
by Kalladdolf
... a totally dumb question.
How do I create a global double array variable in GE (something like var1[var2][var3])?
I mean, GE lets me create a single array. And I could also create the variable manually (in the script).
But it needs to be global and ext int doesn't work.
Meh, I'm sure I'm overlooking a button or something.

Re: Array: This is like...

PostPosted: Sun Apr 05, 2009 8:08 pm
by makslane
Just create in the Global Code Editor. For example, to create a bidimensional integer array:

Code: Select all
int var2d[100][100];


The created var2d array will be accessible in any script.

Re: Array: This is like...

PostPosted: Sun Apr 05, 2009 8:17 pm
by skydereign
Do you mean make the array dynamic without global code? Or just create the array. Because in global code you would just make it like this,
Code: Select all
int ARRAY[x][y];

The only problem with this is that x and y must be predetermined. You could then use a struct wrapper to make it dynamic... Though it sounds like you want to do this with the gameEditor built in tools, which I don't think you can do.

Re: Array: This is like...

PostPosted: Sun Apr 05, 2009 8:30 pm
by Kalladdolf
Well, thanks guys, it doesn't matter to me how it's done, just that I have it there, globally accessible and bidimentional. +1 for both of ya.

Re: Array: This is like...

PostPosted: Mon Apr 06, 2009 7:54 am
by Kalladdolf
Okay, something else has just turned up: Runtime Error: "WRITE attempted before allowed access area."
What's that mean?

Re: Array: This is like...

PostPosted: Mon Apr 06, 2009 10:55 am
by makslane
Make sure the index used in the array is >= 0 and < the declarated limit.

Re: Array: This is like...

PostPosted: Mon Apr 06, 2009 3:56 pm
by Fuzzy
It means you are trying to write outside the limits of the array.

The array runs from 0 to size-1. So an array of 100 is from 0 to 99.

Re: Array: This is like...

PostPosted: Mon Apr 06, 2009 5:02 pm
by Kalladdolf
Right now I was not exceeding the limit... I was just using variables as index(es).
Well, I'll try to set the appropriate "if"-conditions. Maybe it'll work then...
EDIT: It worked. Finally. Be back with more array issues later (hopefully not).
Thanks so far.