two dimensional array

Started by habi, Feb 09, 2020, 04:28 PM

Previous topic - Next topic

habi

i was working with something and finally found a solution. i hope this helps someone.
ALL<-array(100);
local i=0;
for(i=0;i<100;i++)ALL[i]={wep=0,score=0,kills=0};

and isn't it something like two dimensional arrays?

i tried guys, eg.ALL[0].score=99
ALL[1].score=100
ALL[99].score=55
print(ALL[1].score)
[SCRIPT] 100
print(ALL[0].score)
[SCRIPT] 99
print(ALL[99].score)
[SCRIPT] 55
print(ALL[0].kills)
[SCRIPT] 0
etc, etc.

you understand how much power this has..huh?

DizzasTeR

I'm sorry but what?

This is not a two dimensional array, you just made an array named ALL of 100 elements where each element stores a table with 3 indexes namely wep, score and kills initialized at 0

I'd suggest you get your English abit better and try to read the documentation to get a better idea rather than just using words like "dimensional arrays" while not having the concept of it.

habi

#2
hey doom doom doom wait

is not it you see, like, ALL[0][0] and ALL[0].wep kinda same.?

that is it. i noted and it is difficult to use ALL[0][0], because, we have to remember 0 means wep, 1 means score, 2 means what, etc.

thanks.

DizzasTeR

Yes but isn't this just the general idea of if you know how tables work in Squirrel? It really is not that big of a surprise, in-fact people do this all the time in their account classes that handle statistics, which uses a similar kind of approach and syntax, storing class objects in player id indexed arrays...