Got it. I need to learn about these fancy metamethods.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
bump.lua - minimal collision detection lib
- dreadkillz
- Party member
- Posts: 223
- Joined: Sun Mar 04, 2012 2:04 pm
- Location: USA
Re: bump.lua - minimal collision detection lib
- 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
@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.
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".
In case it's not clear, these two are equivalent:dreadkillz wrote:So for the above code, you are passing ("coins: %d") to format?
Code: Select all
("coins: %d"):format(player.coins)
string.format("coins: %d", player.coins)
When I write def I mean function.
Re: bump.lua - minimal collision detection lib
That was it for me too. Works fine nowI think I've found the issue
- ishkabible
- Party member
- Posts: 241
- Joined: Sat Oct 23, 2010 7:34 pm
- Location: Kansas USA
Re: bump.lua - minimal collision detection lib
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.
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.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: bump.lua - minimal collision detection lib
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
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'
- 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
You probably have an old demo. Try downloading it again.munchor wrote:I'm getting that error with the demo.
When I write def I mean function.
Re: bump.lua - minimal collision detection lib
I got mine from github :S
- 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
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:
From that moment on, you can switch back to the master branch doing
And to see the demo again:
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
Code: Select all
git checkout master
Code: Select all
git checkout demo
When I write def I mean function.
Re: bump.lua - minimal collision detection lib
Thank you! This time it worked perfectly
Who is online
Users browsing this forum: Bing [Bot] and 3 guests