Arrays

Posted by Madrox on Wed 01 Nov 2006 11:14 PM — 7 posts, 28,484 views.

#0
Okay, so I've been talking to a friend, about making a healing system for a mud, Imperian. He uses LUA and has tables, I was wondering if there was a way to do something similar with arrays as there are tables in lua. Cause each spot of his table contains two variables. Is that possible with arrays, i've read the help files for them. But they only show examples for 1 peice of input into the array.
Australia Forum Administrator #1
See the post by Ksilyan in the thread:

http://www.gammon.com.au/forum/?id=6529

He shows how to do that (last post on the page).


Amended on Thu 02 Nov 2006 01:40 AM by Nick Gammon
#2
Nooo, I ment in VB, can you store two variables in one "spot" of an array. Like "dogbreed age" being seperate vars.
USA #3
Storing two variables in one "spot" is the same thing as a two-dimensional array where the first size is the number of "spots" (indices) you want and the second size is simply 2. So basically, you are creating a matrix, it's just a very simple matrix.

This is fairly easy to do in VB script. Let's say you want 10 pairs. You'd do:

Dim MyArray(10, 2)

then to get at a pair:

MyArray(1)

or a slot of the pair:

MyArray(1)(1)
#4
Okay, so once I get all teh data from a row, how do I seperate it?
Australia Forum Administrator #5
It would help us to answer these questions if you post an example of what you are trying to do.

"Seperate the data" is not a concept I am really familiar with, so if you post your code, it makes it clearer what you are doing.
#6
function CureHerbAff()
affn = 0
affp = 0
if (miscafftable[7].state) then
if AbleImm() then CureCyanide() end
end
for k in herbafftable do
if (herbafftable[k].state) then
affn = affn + herbafftable[k].affvalue
affp = affp + herbafftable[k].purgevalue
if ((AbleEat()) and (haveherb[herbafftable[k].cure])) then
CureEat(herbafftable[k].cure)
end
end
end
return affn
end


Basicly what that does in lua is read one line of a table or 1 line of an array in vb i soppose it would be. But I don't know how to duplicate it in vb, that's what I'm having trouble with.