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 .
ITISTHEBKID
Prole
Posts: 8 Joined: Sun Nov 11, 2018 9:45 pm
Post
by ITISTHEBKID » Sun Nov 11, 2018 9:57 pm
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: 877 Joined: Sat Dec 10, 2011 7:18 pm
Post
by veethree » Mon Nov 12, 2018 5:38 am
You need to define A as a table inside Z.
zorg
Party member
Posts: 3465 Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:
Post
by zorg » Mon Nov 12, 2018 6:30 am
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
Post
by ITISTHEBKID » Sat Nov 17, 2018 5:19 pm
Is there a way to make it so things can go through Z into A?
pgimeno
Party member
Posts: 3656 Joined: Sun Oct 18, 2015 2:58 pm
Post
by pgimeno » Sat Nov 17, 2018 5:29 pm
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
Users browsing this forum: Ahrefs [Bot] and 6 guests