bump.lua - minimal collision detection lib

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
dreadkillz
Party member
Posts: 223
Joined: Sun Mar 04, 2012 2:04 pm
Location: USA

Re: bump.lua - minimal collision detection lib

Post by dreadkillz »

Nixola wrote:Yes, it's passing a string to "string.format"; every string has a metatable with the field __index similar to this:

Code: Select all

function(t, i) return string[i] end
Got it. I need to learn about these fancy metamethods.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: bump.lua - minimal collision detection lib

Post by kikito »

@ishkabible: I think I've found the issue - it was related with the way I calculated the friction (which is not part of the lib). I updated the demo. Please try it again.
dreadkillz wrote:So for the above code, you are passing ("coins: %d") to format? :crazy:
In case it's not clear, these two are equivalent:

Code: Select all

("coins: %d"):format(player.coins)
string.format("coins: %d", player.coins)
Notice that you have to put parenthesis around the string to use the first notation. Otherwise (if you print "coins: %d":format(...) ) the Lua parser "complains".
When I write def I mean function.
Zeliarden
Party member
Posts: 139
Joined: Tue Feb 28, 2012 4:40 pm

Re: bump.lua - minimal collision detection lib

Post by Zeliarden »

I think I've found the issue
That was it for me too. Works fine now
User avatar
ishkabible
Party member
Posts: 241
Joined: Sat Oct 23, 2010 7:34 pm
Location: Kansas USA

Re: bump.lua - minimal collision detection lib

Post by ishkabible »

kikito: it's fixed :)

I've always disliked how Lua handles that bit of syntax. variables, table constructors, strings, numbers, nil, true, false, etc... should all be treated the same by the parser but alas, Lua decided to give a bit of special syntax to variables and () :/

also the speceil function call syntax only allows for strings and table constructors when it should allow for variables, numbers, nil, true, false, etc...

Lua's idea of a primary expression is strange.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: bump.lua - minimal collision detection lib

Post by bartbes »

The parentheses are merely for grouping, it's just a limitation of the parser. That said, everything is treated the same, (table):method() works too, and the colon syntax works for every kind of variable. Now, what you are mistaken not being able to use it for, is not being able to set a metatable. (So (3):something() could work, but since you can't set a metatable, you can't tell it where to look.)
munchor
Prole
Posts: 39
Joined: Sun Jun 10, 2012 4:28 pm

Re: bump.lua - minimal collision detection lib

Post by munchor »

Code: Select all

Error: main.lua:35: attempt to call field 'check' (a nil value)
stack traceback:
	main.lua:35: in function 'update'
	[string "boot.lua"]:407: in function <[string "boot.lua"]:373>
	[C]: in function 'xpcall'
I'm getting that error with the demo.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: bump.lua - minimal collision detection lib

Post by kikito »

munchor wrote:I'm getting that error with the demo.
You probably have an old demo. Try downloading it again.
When I write def I mean function.
munchor
Prole
Posts: 39
Joined: Sun Jun 10, 2012 4:28 pm

Re: bump.lua - minimal collision detection lib

Post by munchor »

I got mine from github :S
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: bump.lua - minimal collision detection lib

Post by kikito »

Mm. I think I know what happened. You downloaded the master branch, where I had left an old main.lua file by mistake. Sorry for having confused you. I've removed that file now.

The master branch only has the bump.lua file, the README and the license. The demo is on a different branch, called "demo", and it has more files. You can see them via the "branch" dropdown in the github page.

Or you can download the .love file of the demo directly from the downloads section - the file there should always be up to date.

If you have cloned the repo, you can see the demo branch by doing this inside the repo folder:

Code: Select all

git checkout -b demo origin/demo
From that moment on, you can switch back to the master branch doing

Code: Select all

git checkout master
And to see the demo again:

Code: Select all

git checkout demo
When I write def I mean function.
munchor
Prole
Posts: 39
Joined: Sun Jun 10, 2012 4:28 pm

Re: bump.lua - minimal collision detection lib

Post by munchor »

Thank you! This time it worked perfectly :)
Post Reply

Who is online

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