Could you place the line
Code: Select all
print(key, bindings[key])
Code: Select all
if bindings[key] then bindings[key]() end
Code: Select all
print(key, bindings[key])
Code: Select all
if bindings[key] then bindings[key]() end
Except that shouldn't be the case, as bindings is defined in load(), which is called after the whole of the file has been interpreted.TheLinx wrote:It could be because the functions Up, Down, Left and Right possible haven't been defined when you create that table.
Try putting the table in the end of the file, and see what you get.
I wouldn't say it was a waste of time.tido170 wrote:I got it to work, sorry for wasting your time.
Ah, not implemented behavior was one thing I didn't think of.tido170 wrote:It was supposed to move the background when I pressed "d" but my function didn't work so I though the binding didn't.
Code: Select all
bindings[key] = what
Code: Select all
bindings[key] = P1Right
Code: Select all
what = "P1Right"
bindings[key] = what
Code: Select all
bindings[key] = "P1Right"
Code: Select all
if what == "P1Right" then
bindings[key] = P1Right
elseif what == "P1Left" then
bindings[key] = P1Left
and so...
Code: Select all
_G[what]
Code: Select all
what = "P1Right"
bindings[love.key_d] = _G[what] -- equivalent to bindings[love.key_d] = P1Right
Users browsing this forum: Bing [Bot] and 1 guest