wiremod-svn-archive/wire/lua/entities/gmod_wire_dataplug/init.lua

70 lines
1.5 KiB
Lua
Raw Normal View History

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
local MODEL = Model( "models/hammy/pci_card.mdl" )
ENT.WireDebugName = "DataPlug"
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
self.Memory = nil
self.Inputs = Wire_CreateInputs(self.Entity, { "Memory" })
self:SetOverlayText( "Data plug" )
end
function ENT:OnRemove()
self.BaseClass.Think(self)
if (self.MySocket) and (self.MySocket:IsValid()) then
self.MySocket.MyPlug = nil
end
end
function ENT:Setup(a,ar,ag,ab,aa)
self.A = a or 0
self.AR = ar or 255
self.AG = ag or 0
self.AB = ab or 0
self.AA = aa or 255
self.Entity:SetColor(ar, ag, ab, aa)
end
function ENT:TriggerInput(iname, value, iter)
if (iname == "Memory") then
self.Memory = self.Inputs.Memory.Src
if (self.MySocket) and (self.MySocket:IsValid()) then
self.MySocket:SetMemory(self.Memory)
end
end
end
function ENT:SetSocket(socket)
self.MySocket = socket
if (self.MySocket) and (self.MySocket:IsValid()) then
self.MySocket:SetMemory(self.Memory)
end
end
function ENT:AttachedToSocket(socket)
socket:SetMemory(self.Memory)
end
function ENT:OnRestore()
self.A = self.A or 0
self.AR = self.AR or 255
self.AG = self.AG or 0
self.AB = self.AB or 0
self.AA = self.AA or 255
self.BaseClass.OnRestore(self)
end