2007-02-04 01:16:06 +00:00
|
|
|
|
|
|
|
AddCSLuaFile( "cl_init.lua" )
|
|
|
|
AddCSLuaFile( "shared.lua" )
|
|
|
|
include('shared.lua')
|
|
|
|
|
|
|
|
ENT.WireDebugName = "Output"
|
|
|
|
|
|
|
|
local MODEL = Model("models/jaanus/wiretool/wiretool_output.mdl")
|
|
|
|
|
2007-04-18 01:26:09 +00:00
|
|
|
local keylist = {"0","1","2","3","4","5","6","7","8","9",".","Enter","+","-","*","/"}
|
2007-02-04 01:16:06 +00:00
|
|
|
|
|
|
|
function ENT:Initialize()
|
|
|
|
self.Entity:SetModel( MODEL )
|
|
|
|
self.Entity:PhysicsInit( SOLID_VPHYSICS )
|
|
|
|
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
|
|
|
|
self.Entity:SetSolid( SOLID_VPHYSICS )
|
|
|
|
|
|
|
|
self:SetOn( false )
|
|
|
|
|
|
|
|
self.Inputs = Wire_CreateInputs(self.Entity, { "A" })
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function ENT:TriggerInput(iname, value)
|
|
|
|
if (iname == "A") then
|
|
|
|
if ((value > 0) ~= self:IsOn()) then
|
|
|
|
self:Switch(not self:IsOn(), self:GetPlayer())
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function ENT:Switch( on, ply )
|
|
|
|
local plyindex = self:GetPlayerIndex()
|
|
|
|
local key = self:GetKey()
|
|
|
|
|
|
|
|
if (not key) then return end
|
|
|
|
|
|
|
|
if (on) then
|
|
|
|
numpad.Activate( ply, _, {key}, plyindex )
|
|
|
|
else
|
|
|
|
numpad.Deactivate( ply, _, {key}, plyindex )
|
|
|
|
end
|
|
|
|
|
|
|
|
self:SetOn(on)
|
|
|
|
end
|
|
|
|
|
2007-04-18 01:26:09 +00:00
|
|
|
function ENT:ShowOutput()
|
|
|
|
if (self.key) then
|
2007-11-22 20:56:41 +00:00
|
|
|
if (keylist[self.key + 1]) then
|
|
|
|
self:SetOverlayText("Numpad Output ("..keylist[self.key + 1]..")")
|
|
|
|
end
|
2007-04-18 01:26:09 +00:00
|
|
|
end
|
|
|
|
end
|
2007-02-04 01:16:06 +00:00
|
|
|
|
|
|
|
function ENT:SetKey( key )
|
|
|
|
self.Key = key
|
2007-04-18 01:26:09 +00:00
|
|
|
self:ShowOutput()
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:GetKey()
|
|
|
|
return self.Key
|
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:SetOn( on )
|
|
|
|
self.On = on
|
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:IsOn()
|
|
|
|
return self.On
|
|
|
|
end
|