2007-02-04 01:16:06 +00:00
|
|
|
AddCSLuaFile( "cl_init.lua" )
|
|
|
|
AddCSLuaFile( "shared.lua" )
|
|
|
|
|
|
|
|
include('shared.lua')
|
|
|
|
|
|
|
|
ENT.WireDebugName = "GPS"
|
|
|
|
|
|
|
|
function ENT:Initialize()
|
|
|
|
self.Entity:PhysicsInit( SOLID_VPHYSICS )
|
|
|
|
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
|
|
|
|
self.Entity:SetSolid( SOLID_VPHYSICS )
|
|
|
|
|
2007-07-03 18:53:26 +00:00
|
|
|
self.storedpositions = {};
|
|
|
|
self.arrayindex = 0;
|
|
|
|
|
|
|
|
self.Inputs = Wire_CreateInputs(self.Entity, { "Store/Save Pos", "Next", "Remove Save Position"})
|
2008-02-06 01:21:09 +00:00
|
|
|
self.Outputs = WireLib.CreateSpecialOutputs( self.Entity, { "X", "Y", "Z", "Vector", "Recall X", "Recall Y", "Recall Z", "Recall Vector", "Current Memory"}, { "NORMAL", "NORMAL", "NORMAL", "VECTOR", "NORMAL", "NORMAL", "NORMAL", "VECTOR", "NORMAL"})
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:Setup()
|
|
|
|
self.Value = 0
|
|
|
|
self.PrevOutput = nil
|
|
|
|
|
2007-05-06 04:08:32 +00:00
|
|
|
//self:ShowOutput(0, 0, 0)
|
2007-02-04 01:16:06 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "X", 0)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Y", 0)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Z", 0)
|
2008-02-06 01:21:09 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "Vector", Vector(0,0,0))
|
2007-07-03 18:53:26 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "Recall X", 0)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Recall Y", 0)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Recall Z", 0)
|
2008-02-06 01:21:09 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "Recall Vector", Vector(0,0,0))
|
2007-07-03 18:53:26 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "Current Memory", 0)
|
2007-02-04 01:16:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ENT:Think()
|
|
|
|
self.BaseClass.Think(self)
|
|
|
|
|
|
|
|
local pos = self.Entity:GetPos()
|
|
|
|
Wire_TriggerOutput(self.Entity, "X", pos.x)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Y", pos.y)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Z", pos.z)
|
2008-02-06 01:21:09 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "Vector", pos)
|
2007-07-03 18:53:26 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "Current Memory", self.arrayindex)
|
|
|
|
if self.arrayindex > 0 then
|
2007-07-16 22:15:25 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "Recall X", self.storedpositions[self.arrayindex].x)
|
2007-07-03 18:53:26 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "Recall Y", self.storedpositions[self.arrayindex].y)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Recall Z", self.storedpositions[self.arrayindex].z)
|
2008-02-06 01:21:09 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "Recall Vector", self.storedpositions[self.arrayindex])
|
2007-07-03 18:53:26 +00:00
|
|
|
else
|
|
|
|
Wire_TriggerOutput(self.Entity, "Recall X", 0)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Recall Y", 0)
|
|
|
|
Wire_TriggerOutput(self.Entity, "Recall Z", 0)
|
2008-02-06 01:21:09 +00:00
|
|
|
Wire_TriggerOutput(self.Entity, "Recall Vector", Vector(0,0,0))
|
2007-07-03 18:53:26 +00:00
|
|
|
end
|
2007-02-04 01:16:06 +00:00
|
|
|
|
|
|
|
self.Entity:NextThink(CurTime()+0.04)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2007-07-03 18:53:26 +00:00
|
|
|
function ENT:TriggerInput(iname, value)
|
|
|
|
if (iname == "Store/Save Pos") then
|
|
|
|
if (value ~= 0) then
|
|
|
|
local curpos = self.Entity:GetPos()
|
|
|
|
table.insert(self.storedpositions, curpos)
|
|
|
|
self.arrayindex = self.arrayindex+1
|
|
|
|
end
|
|
|
|
elseif (iname == "Next") then
|
|
|
|
if (value ~= 0) then
|
|
|
|
if # self.storedpositions > 0 then
|
|
|
|
if not (self.arrayindex >= # self.storedpositions) then
|
|
|
|
self.arrayindex = self.arrayindex+1;
|
|
|
|
else
|
|
|
|
self.arrayindex = 1; --loop back
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif (iname == "Remove Save Position") then
|
|
|
|
if (value ~= 0) then
|
|
|
|
if self.arrayindex ~= 0 then
|
|
|
|
table.remove(self.storedpositions, self.arrayindex)
|
|
|
|
end
|
|
|
|
if (self.arrayindex == 1) and (# self.storedpositions == 0) then
|
|
|
|
self.arrayindex = 0
|
|
|
|
end
|
|
|
|
if (self.arrayindex == (# self.storedpositions+1)) then
|
|
|
|
self.arrayindex = self.arrayindex-1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|