question about tables [SOLVED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
test
Prole
Posts: 28
Joined: Sun Apr 14, 2019 2:36 pm

question about tables [SOLVED]

Post 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)
Last edited by test on Fri May 17, 2019 9:55 am, edited 1 time in total.
User avatar
NotARaptor
Citizen
Posts: 59
Joined: Thu Feb 22, 2018 3:15 pm

Re: question about tables

Post 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
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: question about tables

Post 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.
Darlex
Party member
Posts: 128
Joined: Sun Sep 24, 2017 10:02 am
Location: Chile
Contact:

Re: question about tables

Post 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)
Hi! I wish you have an amazing day!
Post Reply

Who is online

Users browsing this forum: slime and 46 guests