multidimensional arrays

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

multidimensional arrays

Post by $oldier Of Ra »

Okay, I think I'm getting the hang of it. It seems so simple but I don't think the human brain was made to understand it.
Here's what I think it works:

When I say dimension those 4 column(=dimension) values aren't going to
travel through time! It's just like excel, and you give all boxes a name, example:

......col1 col2 col3
[0]..[4].[5.5].[22] //all this is
......[2].[1.7].[21] //part of
......[7].[8.1].[44] //row 0, it
......[1].[3.4].[16] //just got branched

So:
ocal.array[0] = "test"
local.array[0][0] = 4
local.array[0][1] = 2
local.array[0][2] = 7
local.array[0][3] = 1
local.array[0][0][0] = 5.5
local.array[0][0][1] = 1.7
local.array[0][0][2] = 8.1
local.array[0][0][3] = 3.4
local.array[0][0][0][0] = 22
local.array[0][0][0][1] = 21
local.array[0][0][0][2] = 44
local.array[0][0][0][3] = 16

I hope I got it. (I need to use .... dots because forums always remove tabs and double spaces etc...)
If so, then I guess stuff like local.array[0][2][3][1] is pretty complicated stuff!!!

EDIT: :) the above is unlogical, don't pay attention to this
Last edited by $oldier Of Ra on Tue Nov 11, 2008 5:20 pm, edited 3 times in total.
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Uhm well, in mohaa a multidimensional array is simply an array of arrays.

So say you have one array
local.a = "lol"::"haha"::"hihi"

and another one, which need not be the same size (!) :
local.b = "hehehe"::"uhuh"

You could make a two dimensional array:

local.c = local.a :: local.b

Then:
local.c[0] == local.a
local.c[1] == local.b

Therefore:
local.c[0][1] == "haha"
lcoal.c[1][0] == "hehehe"

:)

This means that in your case

local.array[0] = "test"

would not make sense.
Image
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

jv_map wrote:Uhm well, in mohaa a multidimensional array is simply an array of arrays.

So say you have one array
local.a = "lol"::"haha"::"hihi"

and another one, which need not be the same size (!) :
local.b = "hehehe"::"uhuh"

You could make a two dimensional array:

local.c = local.a :: local.b

Then:
local.c[0] == local.a
local.c[1] == local.b

Therefore:
local.c[0][1] == "haha"
lcoal.c[1][0] == "hehehe"

:)

This means that in your case

local.array[0] = "test"

would not make sense.
Hmm, touch?! :D okay so besides the "test" mistake, my post makes sense?
Anyways, thx jv for the explanation jv!! :D
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Okay I just realized everything I put there makes no sense :s
Let me try again but simpler: (I'm not good at maths, so you know :D)

local.a = "bi"::"boo"::"bah"
local.b = "fi"::"foo"::"fah"
local.c = "di"::"doo":"dah"
local.d = "mi"::"moo"::"mah"

if local.s = local.a::local.c

so:
local.s[0][2] = "bah"
local.s[1][1] = "doo"
local.s[2][0] = NIL

and if local.s = local.b::local.c::local.d
then:
local.s[0] = local.b
local.s[1] = local.c
local.s[2] = local.d

so:
local.s[2][0] = "mi"

and if local.s = (local.b::local.c)::local.d
then(this I don't really get):
local.s[0][0] = local.b
local.s[0][1] = local.c
...uhm... :oops:
local.s[1] = local.d??

so...local.s[0] is an array with 2 more arrays?
then this must be correct?

local.s[0][0][2] = "fah" because local.s[0][0] is local.b and the 2nd (actually 3rd) of local.b is "fah"?




I've also been experimenting with stuff like local.s.size, it doesn't seem to count the 0 entries of the array...for example:


local.s[0][0] = "test1"
local.s[0][1] = "test2"
local.s[1][0] = "hello1"
local.s[1][1] = "hello2"

if you print the local.s.size like so:
println "**************"
println local.s.size
println "**************"

Your console will print this:
**************
3
**************

He doesn't seem to count local.s[0][0], he only counts the ones with at least 1 non-zero entry. But in reality, there are 4
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Oh sorry, I got confused :oops: . These arrays start counting at one, so the first entry would be local.s[1]. My previous example should read:

Then:
local.c[1] == local.a
local.c[2] == local.b

Therefore:
local.c[1][2] == "haha"
local.c[2][1] == "hehehe"

This may explain why the first entry wasn't counted.
Image
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Oh I see!! But apparently, you can still add entries to [0]?
Like in an origin:

local.origin = ( 22 55 33 )

You need to start at 0 to 1 and 2.

And like this:
local.b[0] = "lol0"
this still works as well.

Is this because, for example:
local.a = "bi"::"boo"::"bah"
is a constant array? So in what arrays do you start or can you use [0]?

(speculating) Or perhaps I'm trying to tell the game my local.b is a vector array which explains why [0] works there.
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Post Reply