Topic:   Multi Array!   (Read 3024 times)


0 Members and 1 Guest are viewing this topic.

power


  • Guest
Multi Array!
« on: January 21, 2015, 11:56:06 AM »
I realized that SilverCreator doesn't allow me to use multi-dimensional arrays, nor does it allow me to have variables of different types in an array. You also can't pass arrays as arguments to methods.

So I decided to "fix" that. Here's a simple API with 7 methods:

MARRAY()
Create an empty multi array and returns its ID -- store it in a Number variable to manipulate the array.

APPENDMARRAY(ID, x)
APPENDMARRAYSTR(ID, x$)

Append value to multi array.

SETMARRAY(ID, index, x)
SETMARRAYSTR(ID, index, x$)

Modify index of multi array. Note that you can't change the variable type of an element.

GETMARRAY(ID, index)
GETMARRAY$(ID, index)

Get index of multi array.


All variables and helper methods used internally by the API are prefixed with _scma_, so you can use it in your code and not worry about name clashes due to all variables being global.

I'm a terrible game designer, but I'll see if I can come up with some example code later :)

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Multi Array!
« Reply #1 on: January 21, 2015, 03:03:23 PM »
Impressive work!