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 » Thu May 09, 2019 9:34 am

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 » Thu May 09, 2019 9:49 am

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: 1951
Joined: Mon Jun 17, 2013 12:00 pm

Re: question about tables

Post by raidho36 » 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.

User avatar
Darlex
Party member
Posts: 118
Joined: Sun Sep 24, 2017 10:02 am
Location: absolutely not Chile
Contact:

Re: question about tables

Post by Darlex » Sun May 12, 2019 8:52 pm

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)
culdud uwu

Post Reply

Who is online

Users browsing this forum: Romner and 14 guests