How to make a game with LOVE?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: How to make a game with LOVE?

Post by Karai17 »

It makes you a bad person.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: How to make a game with LOVE?

Post 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.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: How to make a game with LOVE?

Post by Karai17 »

You monster.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: How to make a game with LOVE?

Post by arampl »

How to do this better way then?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How to make a game with LOVE?

Post 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.
When I write def I mean function.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: How to make a game with LOVE?

Post 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.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: How to make a game with LOVE?

Post 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.
User avatar
ffive
Prole
Posts: 16
Joined: Wed Oct 22, 2014 3:22 pm

Re: How to make a game with LOVE?

Post 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
.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests