I am searching for a method to catch a pressed key in LUA. In the help file I found a method oapi.keydown(kstate,<Scanode_of_key>) but I get a error message, when I call it: oapi_keydown: argument1: invalid type (expected handle).
This is what I tried so far:
I think the problem is kstate. It seems that the called C function needs a pointer here, but as far as I know LUA does not know anything about pointers.
The purpose is to do custom things in Orbiter for example gear down with the key combination Ctrl-G and gear up with Alt-G for use with a gear switch.
This is what I tried so far:
Code:
kstate = {}
for i=1,256 do kstate[i] = string.char(0) end
function _test1()
kstate[OAPI_KEY.V] = string.char(0x80)
if oapi.keydown(kstate[OAPI_KEY.V],OAPI_KEY.V) then
term.out('V')
return true
end
return false
end
I think the problem is kstate. It seems that the called C function needs a pointer here, but as far as I know LUA does not know anything about pointers.
The purpose is to do custom things in Orbiter for example gear down with the key combination Ctrl-G and gear up with Alt-G for use with a gear switch.