3D array
Posted by szepi on April 24, 2007
An extesnion that lets you create 3 dimensional arrays for your games. Help file included! The values can only be numbers.
New in v1.2:
Bug fixed
1 New function
» Add a Screenshot
Functions:
Creates a new 3D array with the parameters width, height and depth. It also requires an initial value to store. The function return the id of the the 3D array that is needed to use other functions.
Returns id of array
Assigns the value value to the x, y, z place of the 3D array: id.
Returns if error occured
Returns the value of the x, y, z place of the 3D array: id.
Returns needed value, if error occcured
Creates a string containing the information of the 3D array: id. Returns -1 if there is no such id that has been passed to the functions.
Returns string, if error occcured
Creates a 3D array from the string string and returns the id of the new array.
Returns id of new array
Replaces the already existing 3D array whose id is id with the information stored in the string string. Returns -1 if there is a size mismatch.
Returns -1 in case of size mismatch
Comments:
code:
x[0] = 0
y[0] = 0
z[0] = 0
n[0] = 0
caller:
x[argument0] = argument1
etc.
[qoute]
code:
x[0] = 0
y[0] = 0
z[0] = 0
n[0] = 0
caller:
x[argument0] = argument1
etc.
[/qoute]
what do you mean?
that I should use the name[index]=value format? That's not possible with extensions
[quote]
code:
x[0] = 0
y[0] = 0
z[0] = 0
n[0] = 0
caller:
x[argument0] = argument1
etc.
[quote]
sorry for mispelling quote
[quote]
code:
x[0] = 0
y[0] = 0
z[0] = 0
n[0] = 0
caller:
x[argument0] = argument1
etc.
[/quote]
I guess I got it work now..or it doesn't?
And it's not working? or what is the problem..I thought I tested it in every way..
The variables can be called:
x[0] = bla
etc.
Then in scr_store:
x[0] = argument0
then in scr_get_x
return x[argument]
Thats the shortcut method... :)
Sorry..I don't really understand it..you mean this is a shortcut to make a 3D array?
How does it work?
Please tell me an example for at least 2D array, where we want to "array[x,y]=val".
how do you do this with your method?
Okay. The easy way where there is an inbuilt grid already there. I cant be bothered doing an example of creating different data structs.
Anyway: here is the code you need to run first:
var_data_x[0] = 0
var_data_y[0] = 0
Then to store:
var_data_x[argument0] = argument1
var_data_y[argument0] = argument2
Then to get the data:
return var_data_x[argument0]
You would also need to screw around with the arrays to turn it into a table grid and add some other stuff but thats a basic preset one.
Now to show you a 3d one where you can create grids.
Hmmmmmmm.
I'll copy and paste some code later for you...
Schyler.
argument0 is the array index number thing and argument1 & 2 are the values:
set_values(pos,x,y)
ok..
but in my version you define 3 indexes and set only one value.
so they are different.
Anyways, sorry, I forgot about this page for a while :)
I cant really be bothered explaining how to munipulate this anymore but you get the idea. right?
yeah, but yours is not the same as mine..right?
so you have 1 index, and as many values as you want.
I have 3 indexes and 1 value..like the arrays.
only post something that works.
I would really like to see functions like "get_value_x","get_value_y" & "get_value_z", as well as "set_value_x/y/z" -functions. ;) :)
well i can only go up to about 30,30,30 after that it says an array is bigger than 32000. lets hope thats in the next version of 7.x
okay..that might be a problem..
I made this extension a long time ago, and I've found an error after that and I'm not sure if I fixed t or not and whether I've uploaded it here..
I guess I did, 'coz the error was that the reading the 3D array from a file didn't work above 9 :) I'l check it..