Skip to content

Commit 1910e14

Browse files
authored
Better outputs/inputs creation for gates + force Outputs/Inputs creation (#3364)
* Possible fix for missing `self.Outputs` * Create Inputs/Outputs if they don't exist * Minor change * Minor change * Don't create twice
1 parent 7c2cce6 commit 1910e14

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lua/entities/gmod_wire_gate.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ local Wire_EnableGateInputValues = CreateConVar("Wire_EnableGateInputValues", 1,
99

1010
function ENT:Initialize()
1111
self:PhysicsInit(SOLID_VPHYSICS)
12-
self.Inputs = {}
13-
self.Outputs = {}
12+
WireLib.CreateInputs(self, {})
13+
WireLib.CreateOutputs(self, {})
1414
end
1515

1616
function ENT:Setup(action, noclip)

lua/wire/server/wirelib.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,10 @@ end
268268
function WireLib.AdjustSpecialInputs(ent, names, types, descs)
269269
types = types or {}
270270
descs = descs or {}
271-
local ent_ports = ent.Inputs or {}
271+
272+
local ent_ports = ent.Inputs
273+
if not ent_ports then ent_ports = {} ent.Inputs = ent_ports end
274+
272275
for n,v in ipairs(names) do
273276
local name, desc, tp = ParsePortName(v, types[n] or "NORMAL", descs and descs[n])
274277

@@ -319,7 +322,8 @@ function WireLib.AdjustSpecialOutputs(ent, names, types, descs)
319322
types = types or {}
320323
descs = descs or {}
321324

322-
local ent_ports = ent.Outputs or {}
325+
local ent_ports = ent.Outputs
326+
if not ent_ports then ent_ports = {} ent.Outputs = ent_ports end
323327

324328
local ent_mods = ent.EntityMods
325329
if ent_mods then

0 commit comments

Comments
 (0)