misha.physics
Well-known member
- Joined
- Dec 22, 2021
- Messages
- 1,480
- Reaction score
- 2,210
- Points
- 128
- Location
- Lviv
- Preferred Pronouns
- he/him
I have two "clbk_consumebufferedkey" functions.
First:
Second:
Separately they work correctly, but if I place them one after another, then only the last is applied. How can I merge them into one "clbk_consumebufferedkey" function? There is an example of the HST.lua for multiple key commands:
But I don't understand how to do it for my case.
First:
C++:
function clbk_consumebufferedkey(key, down, kstate)
if not down then
return false
end
if oapi.keydown(kstate, OAPI_KEY.G) then
GearStatus = revert_status(GearStatus)
return true
end
return false
end
C++:
function clbk_consumebufferedkey(key, down, kstate)
if oapi.keydown(kstate, OAPI_KEY.LCONTROL) then
if oapi.keydown(kstate, OAPI_KEY.L) then
if LightSwitch == false then
LightSwitch = true
else LightSwitch = false
end
LeftLight.active = LightSwitch
RightLight.active = LightSwitch
TailLight.active = LightSwitch
end
end
end
C++:
function clbk_consumebufferedkey(key, down, kstate)
if not down then -- only process keydown events
return false
end
if oapi.keydown(kstate, OAPI_KEY.LCONTROL) or oapi.keydown(kstate, OAPI_KEY.RCONTROL) then
if key == OAPI_KEY.KEY1 then -- deploy/retract antenna
ant_status = revert_status(ant_status)
return true
elseif key == OAPI_KEY.KEY2 then -- open/close hatch
hatch_status = revert_status(hatch_status)
return true
elseif key == OAPI_KEY.KEY3 then -- open/fold solar arrays
array_status = revert_status(array_status)
return true
end
end
return false
end