Skip to content

Commit a64fab8

Browse files
authored
Minor wire trigger facelift + output forcing (#3485)
1 parent f6bd4b9 commit a64fab8

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

lua/entities/gmod_wire_trigger.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ function ENT:Initialize()
3838
self:SetSolid( SOLID_VPHYSICS )
3939
local phys = self:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end
4040

41-
self.Outputs = WireLib.CreateOutputs(self, { "EntCount", "Entities [ARRAY]" })
41+
self.Outputs = WireLib.CreateOutputs(self, {
42+
"EntCount",
43+
"Entities [ARRAY]",
44+
"Entered (Entity that entered the trigger entity bounds last) [ENTITY]",
45+
"Exited (Entity that left the trigger entity bounds last) [ENTITY]"
46+
})
4247
end
4348

4449
function ENT:Setup( model, filter, owneronly, sizex, sizey, sizez, offsetx, offsety, offsetz )

lua/entities/gmod_wire_trigger_entity.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ function ENT:Reset()
2525
if not IsValid( owner ) then return end
2626
WireLib.TriggerOutput( owner, "EntCount", 0 )
2727
WireLib.TriggerOutput( owner, "Entities", self.EntsInside )
28+
WireLib.TriggerOutput( owner, "Entered", NULL )
29+
WireLib.TriggerOutput( owner, "Exited", NULL )
2830
end
2931

3032
function ENT:StartTouch( ent )
@@ -40,6 +42,7 @@ function ENT:StartTouch( ent )
4042

4143
WireLib.TriggerOutput( owner, "EntCount", #self.EntsInside )
4244
WireLib.TriggerOutput( owner, "Entities", self.EntsInside )
45+
WireLib.TriggerOutput( owner, "Entered", ent, nil, true )
4346

4447
end
4548
function ENT:EndTouch( ent )
@@ -55,5 +58,6 @@ function ENT:EndTouch( ent )
5558

5659
WireLib.TriggerOutput( owner, "EntCount", #self.EntsInside )
5760
WireLib.TriggerOutput( owner, "Entities", self.EntsInside )
61+
WireLib.TriggerOutput( owner, "Exited", ent, nil, true )
5862

5963
end

lua/wire/server/wirelib.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ local function Wire_Link(dst, dstid, src, srcid, path)
583583
WireLib.TriggerInput(dst, dstid, output.Value)
584584
end
585585

586-
function WireLib.TriggerOutput(ent, oname, value, iter)
586+
function WireLib.TriggerOutput(ent, oname, value, iter, force)
587587
if not entIsValid(ent) then return end
588588
if not HasPorts(ent) then return end
589589

@@ -599,7 +599,7 @@ function WireLib.TriggerOutput(ent, oname, value, iter)
599599
value = ty.Zero()
600600
end
601601

602-
if value ~= output.Value or output.Type == "ARRAY" or output.Type == "TABLE" or (output.Type == "ENTITY" and not rawequal(value, output.Value) --[[Covers the NULL==NULL case]]) then
602+
if value ~= output.Value or output.Type == "ARRAY" or output.Type == "TABLE" or (output.Type == "ENTITY" and not rawequal(value, output.Value) --[[Covers the NULL==NULL case]]) or force then
603603
local timeOfFrame = CurTime()
604604
if timeOfFrame ~= output.TriggerTime then
605605
-- Reset the TriggerLimit every frame

lua/wire/stools/trigger.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function TOOL:GetConVars()
6060
end
6161

6262
local function DrawTriggerOutlines( list )
63-
cam.Start3D( LocalPlayer():EyePos(), LocalPlayer():EyeAngles() )
63+
cam.Start3D( EyePos(), EyeAngles() )
6464
for k,ent in pairs( list ) do
6565
local trig = ent:GetTriggerEntity()
6666

0 commit comments

Comments
 (0)