2007-02-04 01:16:06 +00:00
|
|
|
AddCSLuaFile( "cl_init.lua" )
|
|
|
|
AddCSLuaFile( "shared.lua" )
|
|
|
|
|
|
|
|
include('shared.lua')
|
|
|
|
|
|
|
|
ENT.WireDebugName = "Speedo"
|
|
|
|
|
|
|
|
local MODEL = Model("models/jaanus/wiretool/wiretool_speed.mdl")
|
|
|
|
|
|
|
|
function ENT:Initialize()
|
|
|
|
self.Entity:SetModel( MODEL )
|
|
|
|
self.Entity:PhysicsInit( SOLID_VPHYSICS )
|
|
|
|
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
|
|
|
|
self.Entity:SetSolid( SOLID_VPHYSICS )
|
|
|
|
|
2008-02-06 03:08:57 +00:00
|
|
|
self.Outputs = Wire_CreateOutputs(self.Entity, { "Out", "MPH", "KPH" })
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
|
2007-12-04 07:58:30 +00:00
|
|
|
function ENT:Setup( xyz_mode, AngVel )
|
2007-02-04 01:16:06 +00:00
|
|
|
self.XYZMode = xyz_mode
|
2007-12-04 07:58:30 +00:00
|
|
|
self.AngVel = AngVel
|
|
|
|
self:SetModes( xyz_mode,AngVel )
|
|
|
|
|
|
|
|
local outs = {}
|
2007-02-04 01:16:06 +00:00
|
|
|
if (xyz_mode) then
|
2007-12-04 07:58:30 +00:00
|
|
|
outs = { "X", "Y", "Z" }
|
2007-02-04 01:16:06 +00:00
|
|
|
else
|
2008-02-07 02:13:15 +00:00
|
|
|
outs = { "Out", "MPH", "KPH", }
|
2007-12-04 07:58:30 +00:00
|
|
|
end
|
|
|
|
if (AngVel) then
|
|
|
|
table.Add(outs, {"AngVel_P", "AngVel_Y", "AngVel_R" } )
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
2007-12-04 07:58:30 +00:00
|
|
|
Wire_AdjustOutputs(self.Entity, outs)
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:Think()
|
|
|
|
self.BaseClass.Think(self)
|
|
|
|
|
|
|
|
if (self.XYZMode) then
|
|
|
|
local vel = self.Entity:WorldToLocal(self.Entity:GetVelocity()+self.Entity:GetPos())
|
|
|
|
Wire_TriggerOutput(self.Entity, "X", -vel.y)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Y", vel.x)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Z", vel.z)
|
|
|
|
else
|
|
|
|
local vel = self.Entity:GetVelocity():Length()
|
|
|
|
Wire_TriggerOutput(self.Entity, "Out", vel)
|
2008-02-06 03:08:57 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "MPH", vel / 17.6)
|
|
|
|
Wire_TriggerOutput(self.Entity, "KPH", vel * 0.09144)
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
|
2008-02-07 02:13:15 +00:00
|
|
|
if (self.AngVel) then
|
2007-12-04 07:58:30 +00:00
|
|
|
local ang = self.Entity:GetPhysicsObject():GetAngleVelocity()
|
|
|
|
Wire_TriggerOutput(self.Entity, "AngVel_P", ang.y)
|
|
|
|
Wire_TriggerOutput(self.Entity, "AngVel_Y", ang.z)
|
|
|
|
Wire_TriggerOutput(self.Entity, "AngVel_R", ang.x)
|
|
|
|
end
|
|
|
|
|
2007-02-04 01:16:06 +00:00
|
|
|
self.Entity:NextThink(CurTime()+0.04)
|
|
|
|
return true
|
|
|
|
end
|