Skip to content

Commit

Permalink
Merge pull request orbitersim#451 from TheGondos/luadg_fixes
Browse files Browse the repository at this point in the history
[Lua]Fix Lua DG inputs + errors when loading/saving scenario
  • Loading branch information
jarmonik authored Mar 28, 2024
2 parents 78f873c + 44a6dbb commit 4abce94
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Orbitersdk/samples/Lua/DeltaGlider/Src/Airbrake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ end

function Airbrake:clbkConsumeBufferedKey (key, down, kstate)
if KEYMOD_ALT(kstate) or KEYMOD_SHIFT(kstate) then
return 0
return false
end

if key == OAPI_KEY.B then
Expand All @@ -199,9 +199,9 @@ function Airbrake:clbkConsumeBufferedKey (key, down, kstate)
else
self:Extend()
end
return 1
return true
end
return 0
return false
end

function Airbrake:State()
Expand Down
4 changes: 2 additions & 2 deletions Orbitersdk/samples/Lua/DeltaGlider/Src/CockpitLight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ end
function CockpitLight:clbkParseScenarioLine (line)
local match = {}
if scenario_line_match(line, "FLOODLIGHT %d %f", match) then
self.light_mode = math.max (0, math.min (2, math.res[1]))
self.brightness = math.max (0, math.min (1, math.res[2]))
self.light_mode = math.max (0, math.min (2, match.res[1]))
self.brightness = math.max (0, math.min (1, match.res[2]))
return true
end
return false
Expand Down
2 changes: 1 addition & 1 deletion Orbitersdk/samples/Lua/DeltaGlider/Src/ComponentVessel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ end
function ComponentVessel:clbkConsumeBufferedKey(key, down, kstate)
for _, v in ipairs(self.ssys) do
local res = v:clbkConsumeBufferedKey(key, down, kstate)
if res ~= 0 then
if res then
return res
end
end
Expand Down
1 change: 0 additions & 1 deletion Orbitersdk/samples/Lua/DeltaGlider/Src/Deltaglider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,6 @@ end
function DeltaGlider:clbkConsumeBufferedKey (key, down, kstate)
if not down then return false end -- only process keydown events
if self:playback() then return false end -- don't allow manual user input during a playback

return ComponentVessel.clbkConsumeBufferedKey (self, key, down, kstate)
end

Expand Down
6 changes: 3 additions & 3 deletions Orbitersdk/samples/Lua/DeltaGlider/Src/GearControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ end
--------------------------------------------------------------
function GearControl:clbkConsumeBufferedKey (key, down, kstate)
if KEYMOD_ALT(kstate) or KEYMOD_CONTROL(kstate) or KEYMOD_SHIFT(kstate) then
return 0
return false
end
if key == OAPI_KEY.G then
self:RevertGear()
return 1
return true
end
return 0
return false
end

function GearControl:GearState()
Expand Down
6 changes: 3 additions & 3 deletions Orbitersdk/samples/Lua/DeltaGlider/Src/HUDControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ end

function HUDControl:clbkConsumeBufferedKey (key, down, kstate)
if KEYMOD_ALT(kstate) or KEYMOD_SHIFT(kstate) then
return 0
return false
end

if key == OAPI_KEY.H then
Expand All @@ -291,9 +291,9 @@ function HUDControl:clbkConsumeBufferedKey (key, down, kstate)
else
self:ToggleHUDMode()
end
return 1
return true
end
return 0
return false
end

return HUDControl
2 changes: 1 addition & 1 deletion Orbitersdk/samples/Lua/DeltaGlider/Src/InstrumentLight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ end

function InstrumentLight:clbkSaveState (scn)
if self.light_on or self.light_col ~= 0 or self.brightness ~= 0.5 then
oapi.writescenario_string (scn, "INSTRLIGHT", string.format("%d %d %0.2f", self.light_on, self.light_col, self.brightness))
oapi.writescenario_string (scn, "INSTRLIGHT", string.format("%d %d %0.2f", self.light_on and 1 or 0, self.light_col, self.brightness))
end
end

Expand Down

0 comments on commit 4abce94

Please sign in to comment.