nil tpt.register_keypress (function onKey(keychar, keycode, modifiers, eventobj))
function onkey(char, code, mod, evt)
if char == 'f' then
-- eat pudding
-- then disable the key. pudding ran out, or something
tpt.unregister_keypress(onkey)
else
-- don't eat pudding
end
end
tpt.register_keypress(onkey)
It didn't work for me. When I put the following code into autorun.lua, it didn't work (it's supposed to run a file when you press m):
function onkey(char, code, mod, evt)
if char == 'm' then
dofile('mod.lua')
end
end
But when I did this, it said something about an unexpected character:
nil tpt.register_keypress (function onKey)
function onkey(char, code, mod, evt)
if char == 'm' then
dofile('mod.lua')
end
end
What am I doing wrong?
nil tpt.register_keypress (function onKey)
nil
value or nothing interesting. tpt.register_keypress, and then which kind of arguments it wants from you.
function
which itself takes the arguments (keychar, keycode, modifiers, eventobj).
function onkey(char, code, mod, evt)
if char == 'm' then
dofile ('mod.lua')
end
end
tpt.register_keypress(onkey)
function onkey(char, code, mod, evt)
if char == 'm' then
dofile ('mod.lua')
end
end
tpt.register_keypress(onkey)