Page 2 of 8

Re: bump.lua - minimal collision detection lib

Posted: Sat Jun 09, 2012 7:35 pm
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.

Re: bump.lua - minimal collision detection lib

Posted: Sat Jun 09, 2012 7:41 pm
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".

Re: bump.lua - minimal collision detection lib

Posted: Sat Jun 09, 2012 8:14 pm
by Zeliarden
I think I've found the issue
That was it for me too. Works fine now

Re: bump.lua - minimal collision detection lib

Posted: Sun Jun 10, 2012 6:46 pm
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.

Re: bump.lua - minimal collision detection lib

Posted: Sun Jun 10, 2012 7:22 pm
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.)

Re: bump.lua - minimal collision detection lib

Posted: Sun Jun 10, 2012 7:48 pm
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.

Re: bump.lua - minimal collision detection lib

Posted: Sun Jun 10, 2012 8:41 pm
by kikito
munchor wrote:I'm getting that error with the demo.
You probably have an old demo. Try downloading it again.

Re: bump.lua - minimal collision detection lib

Posted: Sun Jun 10, 2012 8:46 pm
by munchor
I got mine from github :S

Re: bump.lua - minimal collision detection lib

Posted: Sun Jun 10, 2012 9:01 pm
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

Re: bump.lua - minimal collision detection lib

Posted: Sun Jun 10, 2012 10:03 pm
by munchor
Thank you! This time it worked perfectly :)