GML Highlighting provided by GameMaker.info
Back
 
#define array_3d_set
//    array_3d_set(name,x,y,z,value)
//
//    Arguments:

//        argument0 = name    (string, identifies your array)
//        argument1 = x       (real, array x coordinate)
//        argument2 = y       (real, array y coordinate)
//        argument3 = z       (real, array z coordinate)
//        argument4 = value   (string or real, value to be stored)

//
//    Returns true if successful
//
//    Note that since this uses nested 2D arrays, and array indices can be
//    no greater than 31999, the size of the 3D is limited several ways:
//        1. The digits of y appended to the digits of z must not exceed 31999

//        2. The product of x and the previous value must not exceed 999999999
//        3. x must not exceed 31999
//
//    Script by RoboBOT

var name,xx,yy,zz,pwr,index;
name=argument0;
xx=argument1;
yy=argument2;
zz=argument3;
pwr=power(10,(real(string_length(string(yy)))-1));
index=zz*(pwr*10)+yy;

if (index>=32000 || xx>=32000 || xx*index>=1000000) {
    show_error("Array out of bounds (Use smaller indices)",false);
    return false;

};
variable_local_array2_set(name+"in",zz,yy,index);
variable_local_array2_set(name+"out",xx,index,argument4);
return true;

#define array_3d_get

//    array_3d_get(name,x,y,z)
//
//    Arguments:
//        argument0 = name    (string, identifies your array)
//        argument1 = x       (real, array x coordinate)

//        argument2 = y       (real, array y coordinate)
//        argument3 = z       (real, array z coordinate)
//
//    Returns the stored value
//
//    Note that since this uses nested 2D arrays, and array indices can be

//    no greater than 31999, the size of the 3D is limited several ways:
//        1. The digits of y appended to the digits of z must not exceed 31999
//        2. The product of x and the previous value must not exceed 999999999
//        3. x must not exceed 31999

var name,xx,yy,zz,pwr,index;
name=argument0;
xx=argument1;
yy=argument2;
zz=argument3;
pwr=power(10,(real(string_length(string(yy)))-1));
index=zz*(pwr*10)+yy;

return (variable_local_array2_get(name+"out",xx,index));