• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Multiple arrays inside another array...

scorpionfight

New Member
Joined
Sep 21, 2008
Messages
111
Reaction score
1
Location
Brazil
How to create multiple arrays inside another array?

Like:
array1 = x
array2 = y
array3 = z

multiple_array = array1, array2, array3

Its possible?

Thanks!
 
It no give error, but not working too.

I using this array in a code like that( \/ ), but I think is the wrong way to use.
Lua:
array1 = {2400,2401}
array2 = {2402,2403}
array3 = {2404,2404}
multiple_array = {array1 = {}, array2 = {}, array3 = {}}
Lua:
if isInArray(multiple_array, item.itemid) then
--do Script

With that, it not receive the values from array1, array2, array3.

Then, I tested now with that:
Lua:
multiple_array = {2400, array1 = {}, array2 = {}, array3 = {}}
And the script works for the 2400(because I put outside of the arrays) only. But I want to know how to receive the values ​​of the arrays inside the multiple_array.
 
Last edited:
I see that you do not know what I meant. Here you have two examples of using this code:
Lua:
-- I 
multiple_array = {array1 = {2400, 2401}, array2 = {2402, 2403}, array3 = {2404, 2404}}
print(multiple_array.array1[1])


-- II
array1_ = {2400, 2401}
array2_ = {2402, 2403}
array3_ = {2404, 2404}
multiple_array = {array1 = array1_, array2 = array2_, array3 = array3_}
print(multiple_array.array1[1])
 
To check isInArray with arrays within an array you need to loop through the array itself.

Lua:
local array = {arr1 = {12, 13}, arr2 = {101, 103}}

for _, v in pairs(array) do
    if type(v) == 'table' then
        if isInArray(v, item.itemid) do
            -- do stuff
        end
    end
end
 
Back
Top