Does the scripting language allow multi-dim arrays of user defined types?
I have this:
Fighters BattleFighters[MAX_FIGHTERS][MAX_ACTIONS];
but it doesn't work. Is this unsupported or did i do something wrong?
No...unfortunately you can't have multidimensional arrays.
So,
Fighters BattleFighters[MAX_FIGHTERS * MAX_ACTIONS];
Should work, and then you can find the correct index with something like
int index = (FIGHTERS_INDEX * MAX_ACTIONS) + ACTIONS_INDEX;
[EDIT:] Just to clarify, you can't have any multi-dimensional arrays at the moment. So basically the format is:
TYPE NAME[a][c]...[n] becomes TYPE NAME[a * b * c * ... * n]
NAME[a_index][b_index][c_index]...[n_index] becomes (a_index * b * c * ... * n) + (b_index * c * ... * n) + (c_index * ... * n) + ... + n_index
Yeah, I think the math there is correct...I'm kind of preoccupied now though so it may not be...
that sucks...what i really wanted was nested types, and this was an attempt to get around it. It just keeps getting worse. ::)
Big arrays aren't necessarily bad...as long as it's under 150000 total members you should be fine. := And if you're working with a beta version (I think beta 4+) then you can use the noloopcheck keyword as well...
Technical Archive:
2D arrays (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=6918.0)
3D arrays (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=13897.0)
I also see no problem with this approach.
Actually, that syntax doesn't work.
MAX_FIGHTERS * MAX_ACTIONS isn't allowed in the array statement. you have to actually do another define with the result.
True, that has bugged me too on occasion. Tracker entry (http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=500).
Well yes, I've experienced that error, but I'm glad that you figured out that by manually figuring out the value and using that instead it will work.
I was just typing up some code to give you the idea for how it works...and as for the math I did a much extended version of the algorithm which can be found on that 3D array page...but like I said it should work...
grrrrr....i need nested types. :'(
That doesn't help.
Quote from: Pumaman on Tue 24/05/2005 19:19:11Yes, it's a possibility for a future version. However, I can't promise any timescales.