dDimension 1.1
dDimension provides a limited array system for unlimited dimensions, see the example below. Please, do read the include file before asking for further information.
Code:
/*
Introduction to dDimension 1.1
*/
#include <amxmodx>
#include <ddimension>
#define PLUGIN "dDimensionExample"
#define VERSION "1.0"
#define AUTHOR "SnoW"
/*
Arrays can be created as global
*/
public plugin_init( )
{
register_plugin( PLUGIN, VERSION, AUTHOR );
f( );
}
f( )
{
/* >
c{ } creates dDimension array
Arrays have always be created at the beginning of a statement ( See how the new/static must be inside the form )
*/
c{ new Float:MyDArray[ 3 ][ 3 ][ 3 ][ 3 ][ 3 ] }, Float: fCount;
/* <
When creating array it is forbidden to not specify a tag, so if no tag is wanted _: can be used
*/
/* >
d{ } loads dDimension array
*/
for( new d1; d1 < 3; d1++ )
for( new d2; d2 < 3; d2++ )
for( new d3; d3 < 3; d3++ )
for( new d4; d4 < 3; d4++ )
for( new d5; d5 < 3; d5++ )
d{ MyDArray[ d1 ][ d2 ][ d3 ][ d4 ][ d5 ] } = fCount += 1.0;
/* >
p{ } passes dDimension array to function
Notice the space missing in the form end, this is right as all characters after the name are forbidden, the very same with g{ }
*/
f2( p{ MyDArray} );
}
/* >
g{ } initializes the array passed
Notice the tag outside of the form, only c{ } accepts tags inside the form
*/
f2( Float: g{ MyPassedDArray} )
{
for( new d1; d1 < 3; d1++ )
for( new d2; d2 < 3; d2++ )
for( new d3; d3 < 3; d3++ )
for( new d4; d4 < 3; d4++ )
for( new d5; d5 < 3; d5++ )
server_print( "%f", d{ MyPassedDArray[ d1 ][ d2 ][ d3 ][ d4 ][ d5 ] } );
}
Developing
The syntax is horrible for my opinion, yet I couldn't come with anything more reasonable. Write a better one and I will be happy to move to that one.
Adding warnings for index out of bounds should be easy, somehow I found that tagof isn't working as it should be ( at least not in our pawn version ), so I'm currently believing that tag mismatch warnings will never be achieved.
I appreciate you developing dDimension. Even if you just used it, add a post below as I will be working with the system only if someone uses it. Thank you for co-operating.