2007-02-04 01:16:06 +00:00
|
|
|
|
|
|
|
AddCSLuaFile( "cl_init.lua" )
|
|
|
|
AddCSLuaFile( "shared.lua" )
|
|
|
|
|
|
|
|
include('shared.lua')
|
|
|
|
|
|
|
|
local MODEL = Model( "models/props_lab/tpplug.mdl" )
|
|
|
|
|
|
|
|
ENT.WireDebugName = "Plug"
|
|
|
|
|
|
|
|
function ENT:Initialize()
|
|
|
|
self.Entity:SetModel( MODEL )
|
|
|
|
self.Entity:PhysicsInit( SOLID_VPHYSICS )
|
|
|
|
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
|
|
|
|
self.Entity:SetSolid( SOLID_VPHYSICS )
|
|
|
|
|
|
|
|
self.MySocket = nil
|
|
|
|
|
2007-05-21 17:11:51 +00:00
|
|
|
self.Inputs = Wire_CreateInputs(self.Entity, { "A","B","C","D","E","F","G","H" })
|
|
|
|
self.Outputs = Wire_CreateOutputs(self.Entity, { "A","B","C","D","E","F","G","H" })
|
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:SetValue(index,value)
|
|
|
|
if (self.MySocket.Const) and (self.MySocket.Const:IsValid()) then
|
|
|
|
Wire_TriggerOutput(self.Entity, index, value)
|
|
|
|
else
|
|
|
|
Wire_TriggerOutput(self.Entity, index, 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
self:ShowOutput()
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:OnRemove()
|
|
|
|
self.BaseClass.Think(self)
|
|
|
|
|
|
|
|
if (self.MySocket) and (self.MySocket:IsValid()) then
|
|
|
|
self.MySocket.MyPlug = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-05-21 17:11:51 +00:00
|
|
|
function ENT:Setup()
|
|
|
|
self:ShowOutput()
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
|
2007-05-21 17:11:51 +00:00
|
|
|
function ENT:TriggerInput(iname, value)
|
|
|
|
self:ShowOutput()
|
|
|
|
if (self.MySocket) and (self.MySocket:IsValid()) then
|
|
|
|
self.MySocket:SetValue(iname, value)
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:SetSocket(socket)
|
|
|
|
self.MySocket = socket
|
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:AttachedToSocket(socket)
|
2007-05-21 17:11:51 +00:00
|
|
|
for i,v in pairs(self.Inputs)do
|
|
|
|
socket:SetValue(v,v.Value)
|
|
|
|
end
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:ShowOutput(value)
|
2007-05-21 17:11:51 +00:00
|
|
|
self:SetOverlayText("Plug")
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:OnRestore()
|
|
|
|
self.BaseClass.OnRestore(self)
|
|
|
|
end
|