Log In  

I'm trying to do something like this:

thing = {}

for an amount of times do
add(thing, {a=5,b=6,c=self.a+self.b})
end

the "self" part isn't working

also in the context of the code, the name of "thing" and the values of "a" and "b" are dynamically changing

cheers for your time : )

P#48860 2018-02-01 19:14 ( Edited 2018-02-02 01:01)

you can't reference a table if it doesn't exist yet. you just have to break up your code into multiple statements, like this

local t = {
  a = 5,
  b = 6
}

t.c = t.a + t.b
P#48861 2018-02-01 19:42 ( Edited 2018-02-02 00:51)

It's not ideal but I think I can work with that, thanks mate

P#48862 2018-02-01 20:01 ( Edited 2018-02-02 01:01)

[Please log in to post a comment]