Skip to content

Commit

Permalink
Allow toggle_engine bind to work on all vehicles
Browse files Browse the repository at this point in the history
  • Loading branch information
StyledStrike committed Jan 20, 2025
1 parent 8c30dd6 commit f1b5bff
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
7 changes: 7 additions & 0 deletions lua/entities/base_glide_aircraft/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ function ENT:OnSeatInput( seatIndex, action, pressed )
if action == "countermeasures" then
self:FireCountermeasures()
return true

elseif action == "toggle_engine" then
if self:GetEngineState() == 0 then
self:TurnOn()
else
self:TurnOff()
end
end
end

Expand Down
13 changes: 13 additions & 0 deletions lua/entities/base_glide_tank/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ function ENT:TurnOff()
self.brake = 0.5
end

--- Implement this base class function.
function ENT:OnSeatInput( seatIndex, action, pressed )
if not pressed or seatIndex > 1 then return end

if action == "toggle_engine" then
if self:GetEngineState() == 0 then
self:TurnOn()
else
self:TurnOff()
end
end
end

--- Override this base class function.
function ENT:OnTakeDamage( dmginfo )
if dmginfo:IsDamageType( 64 ) then -- DMG_BLAST
Expand Down
2 changes: 1 addition & 1 deletion lua/glide/client/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ function Config:OpenFrame()

theme:CreateHeader( panelKeyboard, L"input.general_controls" )
CreateBinderButton( panelKeyboard, L"input.switch_weapon", "switch_weapon", generalBinds.switch_weapon, OnChangeGeneralBind )
CreateBinderButton( panelKeyboard, L"input.toggle_engine", "toggle_engine", generalBinds.toggle_engine, OnChangeGeneralBind )

local landBinds = binds["land_controls"]

Expand All @@ -581,7 +582,6 @@ function Config:OpenFrame()
CreateBinderButton( panelKeyboard, L"input.siren", "siren", landBinds.siren, OnChangeLandBind )
CreateBinderButton( panelKeyboard, L"input.headlights", "headlights", landBinds.headlights, OnChangeLandBind )
CreateBinderButton( panelKeyboard, L"input.reduce_throttle", "reduce_throttle", landBinds.reduce_throttle, OnChangeLandBind )
CreateBinderButton( panelKeyboard, L"input.toggle_engine", "toggle_engine", landBinds.toggle_engine, OnChangeLandBind )

CreateBinderButton( panelKeyboard, L"input.lean_forward", "lean_forward", landBinds.lean_forward, OnChangeLandBind )
CreateBinderButton( panelKeyboard, L"input.lean_back", "lean_back", landBinds.lean_back, OnChangeLandBind )
Expand Down
4 changes: 2 additions & 2 deletions lua/glide/sh_input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Glide.InputCategories = InputCategories

-- Inputs that apply to all vehicle types
InputCategories["general_controls"] = {
["switch_weapon"] = KEY_R
["switch_weapon"] = KEY_R,
["toggle_engine"] = KEY_I
}

-- Inputs that only apply to land vehicle types
Expand All @@ -28,7 +29,6 @@ InputCategories["land_controls"] = {
["siren"] = KEY_L,
["headlights"] = KEY_H,
["reduce_throttle"] = KEY_LSHIFT,
["toggle_engine"] = KEY_I,

["lean_forward"] = KEY_UP,
["lean_back"] = KEY_DOWN,
Expand Down

0 comments on commit f1b5bff

Please sign in to comment.