[SUGGESTION] Multi-Dimensional Arrays

Started by Calin Leafshade, Sat 24/10/2009 09:26:06

Previous topic - Next topic

Calin Leafshade

Now I know this is possible to do using a function and a kind of wrapper for an array which transposes values into appropriate indices but i think having hard coded arrays that can be defined just as Array[100,100] would be a logical addition to the language.

Thoughts?

Scarab

Yeah, this would be really useful for me for programming the tile engine I'm coding at the moment, (I'm currently using the 'wrapper' function you mentioned), although I'm not entirely sure what applications this would have in adventure games.

I mean, if CJ's up for it, high fives all round, but he can only really be expected to add features which predominantly affect the genre AGS was designed for.

Calin Leafshade

MD arrays can be used for loads of things from a mathematical point of view.

The most obvious application i can think of is cartesian coordinates which are used all the time in graphics algorithms.


Khris

Just FYI, you can already "trick" the engine into supporting two dimensional arrays of types like int:

Code: ags
// header

struct str_x {
  int y[100];
};

// script

str_x x[100];

// now one can do:
  x[40].y[20] = 3;


Of course it still isn't possible to do stuff like x[40].y[20].tile = 1;

OneDollar

I'd find inbuilt support for multi-dimensional (or at least 2d) arrays really useful... but I'm trying to make non-adventure games with AGS. I can't think of much use for them in your average adventure game, but if there's enough support maybe CJ will make it a higher priority.

Scarab

#5
Quote from: OneDollar on Sat 24/10/2009 12:30:17
if there's enough support maybe CJ will make it a higher priority.

Woot for e-Petitions! ;D

I mean granted limited adventure game use with this feature, non-adventure games are not that uncommon, and it will just add to AGS's already quite prominent versatility.

Wonkyth

I've also been using AGS to work on various (unfinished) non-adventure games, but the main relevant reason I can come up with is that when trying to transcribe non-AGS code modules, which are plenty to be found, that quite often they require multi-dimensional arrays, and they always assume that they are available.
"But with a ninja on your face, you live longer!"

discordance

Funny, I was just wishing today that ags had two-dimensional arrays. Again, though, it was for a non-adventure project. I don't think I'd ever use them in an AG, but obviously there are plenty of crazy folk who love to use AGS for purposes unintended. :)

Joseph DiPerla

This has been discussed before. Maybe the LUA Plugin might be a good stand in?
Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

RickJ

#9
Quote
I've also been using AGS to work on various (unfinished) non-adventure games, but the main relevant reason I can come up with is that when trying to transcribe non-AGS code modules, which are plenty to be found, that quite often they require multi-dimensional arrays, and they always assume that they are available.
This probably the best reason I've seen for implementing multi-dimensional arrays.  Otherwise the work-arounds work just fine.  Personally I would rather have improved support for stucts, struct in struct, struct and function pointers.  

Wonkyth

As structs are about the most useful thing in the whole scripting language, I'd second that! :)
"But with a ninja on your face, you live longer!"

Shane 'ProgZmax' Stevens

#11
This is probably the third most requested addition to AGS and it's been discussed over and over again.  Yeah, there are work-arounds, yeah it would be great to have native support.  I just wish people would limit their suggestions and ideas to a single collective thread (which they gloss over to make sure it hasn't already been suggested).  Threads like this streamline the process and give CJ one place to look to see all the current popular suggestions instead of having to jump around and look at repetitive posts.

SMF spam blocked by CleanTalk