wiremod-svn-archive/wire/lua/entities/gmod_wire_dataplug/init.lua
BlackPhoenix 0b43bac3b5 [FIXED] Added proper hispeed support for RAM gates (and gates in general)
[FIXED] Removed obsolete code from some hispeed devices
[FIXED] Misc ZASM error
[ADDED] "Connected" outputs to data socket and data plug
[FIXED] Added a neater error display in GPU
[FIXED] Added small fix for when other player removes your keyboard and you cant get out
2008-10-25 12:10:59 +00:00

75 lines
1.6 KiB
Lua

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.Outputs = Wire_CreateOutputs(self.Entity, { "Connected" })
self:SetOverlayText( "Data plug" )
Wire_TriggerOutput(self.Entity, "Connected", 0)
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)
else
Wire_TriggerOutput(self.Entity, "Connected", 0)
end
end
function ENT:AttachedToSocket(socket)
socket:SetMemory(self.Memory)
Wire_TriggerOutput(self.Entity, "Connected", 1)
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