Skip to content

Commit

Permalink
Fixed wire input error when enabling computers
Browse files Browse the repository at this point in the history
- Fixed indexing error when enabling computers due to inputs not being created at the moment they're checked to be updated.
  • Loading branch information
TwistedTail committed Jul 24, 2023
1 parent a81e114 commit afe0215
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions lua/acf/entities/components/computers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,16 @@ do -- Joystick
Entity.Spread = 1 - math.Round(Entity.ACF.Health / Entity.ACF.MaxHealth, 2)
end,
OnEnabled = function(Entity)
if Entity.Inputs.InputPitch.Path then
Entity:TriggerInput("Pitch", Entity.Inputs.InputPitch.Value)
local Inputs = Entity.Inputs
local Pitch = Inputs.InputPitch
local Yaw = Inputs.InputYaw

if Pitch and Pitch.Path then
Entity:TriggerInput("Pitch", Pitch.Value)
end

if Entity.Inputs.InputYaw.Path then
Entity:TriggerInput("Yaw", Entity.Inputs.InputYaw.Value)
if Yaw and Yaw.Path then
Entity:TriggerInput("Yaw", Yaw.Value)
end
end,
OnDisabled = function(Entity)
Expand Down Expand Up @@ -381,12 +385,16 @@ do -- Optical guidance computer
Entity.Spread = 1 - math.Round(Entity.ACF.Health / Entity.ACF.MaxHealth, 2)
end,
OnEnabled = function(Entity)
if Entity.Inputs.InputPitch.Path then
Entity:TriggerInput("Pitch", Entity.Inputs.InputPitch.Value)
local Inputs = Entity.Inputs
local Pitch = Inputs.InputPitch
local Yaw = Inputs.InputYaw

if Pitch and Pitch.Path then
Entity:TriggerInput("Pitch", Pitch.Value)
end

if Entity.Inputs.InputYaw.Path then
Entity:TriggerInput("Yaw", Entity.Inputs.InputYaw.Value)
if Yaw and Yaw.Path then
Entity:TriggerInput("Yaw", Yaw.Value)
end
end,
OnDisabled = function(Entity)
Expand Down Expand Up @@ -591,16 +599,21 @@ do -- Laser guidance computer
Entity.Spread = 1 - math.Round(Entity.ACF.Health / Entity.ACF.MaxHealth, 2)
end,
OnEnabled = function(Entity)
if Entity.Inputs.Lase.Path then
Entity:TriggerInput("Lase", Entity.Inputs.Lase.Value)
local Inputs = Entity.Inputs
local Lase = Inputs.Lase
local Pitch = Inputs.InputPitch
local Yaw = Inputs.InputYaw

if Lase and Lase.Path then
Entity:TriggerInput("Lase", Lase.Value)
end

if Entity.Inputs.InputPitch.Path then
Entity:TriggerInput("Pitch", Entity.Inputs.InputPitch.Value)
if Pitch and Pitch.Path then
Entity:TriggerInput("Pitch", Pitch.Value)
end

if Entity.Inputs.InputYaw.Path then
Entity:TriggerInput("Yaw", Entity.Inputs.InputYaw.Value)
if Yaw and Yaw.Path then
Entity:TriggerInput("Yaw", Yaw.Value)
end
end,
OnDisabled = function(Entity)
Expand Down Expand Up @@ -771,8 +784,10 @@ do -- GPS transmitter
Entity.Spread = ACF.MaxDamageInaccuracy * (1 - math.Round(Entity.ACF.Health / Entity.ACF.MaxHealth, 2))
end,
OnEnabled = function(Entity)
if Entity.Inputs.Coordinates.Path then
Entity:TriggerInput("Coordinates", Entity.Inputs.Coordinates.Value)
local Coordinates = Entity.Inputs.Coordinates

if Coordinates and Coordinates.Path then
Entity:TriggerInput("Coordinates", Coordinates.Value)
end
end,
OnDisabled = function(Entity)
Expand Down

0 comments on commit afe0215

Please sign in to comment.