Page 2 of 2
Re: How to make a game with LOVE?
Posted: Wed Oct 29, 2014 7:41 pm
by Karai17
It makes you a bad person.
Re: How to make a game with LOVE?
Posted: Thu Oct 30, 2014 4:13 am
by arampl
kikito wrote:Karai17 wrote:Tables can also have functions and tables as keys. But don't do that.
Yet.
+1.
I'm using functions as keys in reverse tables (see PiL for reference) to save functions' bindings to GUI controls in text files.
Re: How to make a game with LOVE?
Posted: Thu Oct 30, 2014 4:15 am
by Karai17
You monster.
Re: How to make a game with LOVE?
Posted: Thu Oct 30, 2014 4:21 am
by arampl
How to do this better way then?
Re: How to make a game with LOVE?
Posted: Thu Oct 30, 2014 7:49 am
by kikito
Don't listen to Karai17, he's being obtuse.
There's nothing inherently wrong in using tables or functions as keys. It's just a bit advanced, and it's preferable to learn the basics well first.
Re: How to make a game with LOVE?
Posted: Thu Oct 30, 2014 2:19 pm
by Karai17
Yeah, sorry, I am just being silly. As kikito said, there is nothing inherently wrong with it, but it is a very advanced activity.
Re: How to make a game with LOVE?
Posted: Thu Oct 30, 2014 4:47 pm
by arampl
Never mind.
Actually functions as a tables' keys can be very useful:
Code: Select all
fn1 = function(x) print(x) end
fn2 = function(x) print("bar") end
t[fn1] = "foo"
t[fn2] = "foo"
for i, v in pairs(t) do i(v) end
(from
http://stackoverflow.com/questions/1456 ... table-keys)
Not too difficult to use and can be very powerful imo.
Re: How to make a game with LOVE?
Posted: Fri Oct 31, 2014 4:48 pm
by ffive
arampl wrote:
Actually functions as a tables' keys can be very useful:
Code: Select all
fn1 = function(x) print(x) end
fn2 = function(x) print("bar") end
t[fn1] = "foo"
t[fn2] = "foo"
for i, v in pairs(t) do i(v) end
Weird.
This code runs well. (t was undeclared, so I added t = {})
Looking at the 'for' cycle. v is undeclared, what is pairs?
UPD: Nevermind, found it out.
http://www.lua.org/pil/4.3.5.html