dudeim
Member
- Joined
- Oct 5, 2007
- Messages
- 121
- Reaction score
- 9
Hey,
I'm currently trying to modify variables from a table inside a function that's inside a table.
So why am I getting that error (look at the add function in the table) anyone has an idea?
Thanks!
I'm currently trying to modify variables from a table inside a function that's inside a table.
Lua:
t = {
}
function someFuncThatIsCalled()
for i = 1,10 do
t[i] = {
vals131 = 0, --the value that is changed, I gave it some stupid name so I'm sure it's never used somewhere
add = function()
vals131 = vals131 + 1 --this increases 1 to the value, it gives me an error here: attempt to preform arithmetic on global 'vals131' (a nil value)
end,
sub = function()
vals131 = vals131 - 1 --this substracts 1 from the value
end
}
end
local m = math.random(1,10)
t[m].add()
t[m].add()
print(t[m].vals131)
end
Thanks!