Page 1 of 1

question about tables [SOLVED]

Posted: Thu May 09, 2019 9:34 am
by test

Code: Select all

local p = {}
for i = 1, 2 do p[i] = {x = (2 * i - 1) * w / 4, y = h / 2, w = 100, h = 100, xx = x, yy= y} end
I want to set xx to x and yy to y. But I don't want to do it with a new line(example: p.xx = p.x)

Re: question about tables

Posted: Thu May 09, 2019 9:49 am
by NotARaptor

Code: Select all

local p = {}
for i = 1, 2 do local x, y = (2 * i - 1) * w / 4, h / 2; p[i] = { x=x, y=y, w=100, h=100, xx=x, yy=y } end

Re: question about tables

Posted: Thu May 09, 2019 10:08 am
by raidho36
You should do these each on their own line, use as little of syntax sugar as possible. It's more verbose but it's easier to read which will be very important when you'll be editing it.

Re: question about tables

Posted: Sun May 12, 2019 8:52 pm
by Darlex
raidho36 wrote: Thu May 09, 2019 10:08 am You should do these each on their own line, use as little of syntax sugar as possible. It's more verbose but it's easier to read which will be very important when you'll be editing it.
And it can look really good. (Not like mine, that is spaghetti)