• 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 Need a bit of help with tables

Santi

Theres no way im stopping
Joined
Aug 29, 2010
Messages
1,975
Reaction score
152
Location
00
Lua:
local t = {
[XXXX] = {Values = {{1,3,5,7,9}}, newValues = {}},
[OOOO] = {Values = {{2,4,6,8}}, newValues={}}
}

So basically what Im trying to do is making the Values(of The XXXX) fo to the newValues(of the OOOO). And the values(of the OOOO) go to the newValues(of XXXX).
But since the table calls it(Values and newValues) the same then using table.insert and table.remove will cause both "Values", make the same.
I mean:
Lua:
for a = 1, #v.Values do
    table.insert(newValues, v.Values)
end

This should insert in v.newValues, the stuff in v.Values, but since the both are the same then it will send the same stuff right?(And probably cause a bug?), since its calling 2 and has to put in 2, so I guess it will put all numbers 1-9 into both newValues.
I just dunno how to do it, need some help at it.
Thanks in advanced, any type of help will be appreciated :)
 
nvm seems i miss understood u, but i think as you already have defined keys to the tables so it wont in order of t[1],t[2] it would be t[key] so we cant make a loop through integer keys like i mean :
Lua:
for i = 1,#table do
      table.insert(table[i].new, table[(i == 1 and i+1 or i-1)].value[])
end

So you can make a loop to represent each key in a integer value so u can subtracet or add on it.
 
Last edited:
nvm seems i miss understood u, but i think as you already have defined keys to the tables so it wont in order of t[1],t[2] it would be t[key] so we cant make a loop through integer keys like i mean :
Lua:
for i = 1,#table do
      table.insert(table[i].new, table[(i == 1 and i+1 or i-1)].value[])
end

So you can make a loop to represent each key in a integer value so u can subtracet or add on it.

Still dont get it.
When you call table
for i = 1, #table
then table is table, and if there are 2 tables then it will be fucked up right?
I probably dont get it since im not pro.
And this:
Lua:
[(i == 1 and i+1 or i-1)].value[]
I dont get it :/
 
Back
Top