Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile( "cl_init.lua" )
- AddCSLuaFile( "shared.lua" )
- include('shared.lua')
- function ENT:Initialize()
- self:SetModel("models/props_lab/box01a.mdl")
- self:PhysicsInit(SOLID_VPHYSICS)
- self:SetMoveType(MOVETYPE_VPHYSICS)
- self:SetSolid(SOLID_VPHYSICS)
- self:SetUseType( SIMPLE_USE )
- local phys = self:GetPhysicsObject()
- if IsValid(phys) then
- phys:Wake()
- end
- self.isPlugged = false
- self.connectedDevice = nil
- self.defaultDevice = nil
- end
- function ENT:PlugIn(ent)
- if ent:GetClass() == "ent_computercase" then
- self.isPlugged = true
- self.connectedDevice = ent
- self:SetParent(self.connectedDevice)
- self:SetPos(self.connectedDevice:GetForward() - Vector(13, 0, 0))
- end
- end
- function ENT:UnPlug()
- self.isPlugged = false
- self.connectedDevice = nil
- self:SetParent(nil)
- end
- function ENT:StartTouch(ent)
- if self.defaultDevice:GetClass() != ent:GetClass() then
- self:PlugIn(ent)
- end
- end
- function ENT:Use()
- if self.isPlugged then
- self:UnPlug()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement