## Trouble With Tables [SOLVED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
ITISTHEBKID
Prole
Posts: 8
Joined: Sun Nov 11, 2018 9:45 pm

### Trouble With Tables [SOLVED]

Code: Select all

	function love.load()
A = {B = 0, C = 0}
Z  = {A.B = 3,}
print(Z.A.B)
end

Why does this code spit out an error?
Last edited by ITISTHEBKID on Sat Nov 17, 2018 8:08 pm, edited 1 time in total.

veethree
Inner party member
Posts: 820
Joined: Sat Dec 10, 2011 7:18 pm

### Re: Trouble With Tables

You need to define A as a table inside Z.

Code: Select all

Z  = {A = {B = 3}}

zorg
Party member
Posts: 2936
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: Trouble With Tables

Do note that Z.A.B has absolutely nothing to do with A.B in veethree's solution; they are separate tables.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

ITISTHEBKID
Prole
Posts: 8
Joined: Sun Nov 11, 2018 9:45 pm

### Re: Trouble With Tables

Is there a way to make it so things can go through Z into A?

pgimeno
Party member
Posts: 2211
Joined: Sun Oct 18, 2015 2:58 pm

### Re: Trouble With Tables

Code: Select all

	A = {B = 0, C = 0}
Z  = {A = A}
Z.A.B = 5
A.C = 7
print(Z.A.B) -- prints 5
print(A.B) -- prints 5
print(Z.A.C) -- prints 7
print(A.C) -- prints 7


ITISTHEBKID
Prole
Posts: 8
Joined: Sun Nov 11, 2018 9:45 pm

Thanks so much!

### Who is online

Users browsing this forum: No registered users and 14 guests