table in table

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
User avatar
S-Rave
Prole
Posts: 39
Joined: Wed Feb 25, 2009 4:41 pm

table in table

Post by S-Rave »

Heya!

I was wondering... if I add a "point" with "point.x" and "point.y" to another table at places like points[1] and points[2]... how would I access the x and y?

This is obviously something really simple but I feel like I've tried everything. (Well obviously not since it must be possible)
srejv
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: table in table

Post by osgeld »

points[1].x

assuming your tables are structures like

Code: Select all

osgeld@osgeld:~$ lua
Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> points = {{x = 0, y = 0}}
> print(points[1].x)
0 -- output of print statement
> 
User avatar
S-Rave
Prole
Posts: 39
Joined: Wed Feb 25, 2009 4:41 pm

Re: table in table

Post by S-Rave »

osgeld wrote:points[1].x

assuming your tables are structures like

Code: Select all

osgeld@osgeld:~$ lua
Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> points = {{x = 0, y = 0}}
> print(points[1].x)
0 -- output of print statement
> 
Thanks, it made me check the index, which I then realized I forgot to set the first one (points[1]). :neko:
Works now whohoo! :D

edit: attached the source if anyone was interested in what it was all about :)
Attachments
cuberotate.love
(1.04 KiB) Downloaded 98 times
srejv
User avatar
Xcmd
Party member
Posts: 211
Joined: Fri Feb 13, 2009 10:45 pm

Re: table in table

Post by Xcmd »

That's pretty schwey. Now add textures, champ. :D
We don't borrow, we don't read, we don't rent, we don't lease, we take the minds!
User avatar
S-Rave
Prole
Posts: 39
Joined: Wed Feb 25, 2009 4:41 pm

Re: table in table

Post by S-Rave »

Haha, made a filled cube. Gonna try textures once I get my head around backface culling :]
srejv
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 55 guests