2008-06-14 00:55:20 +00:00
|
|
|
AddCSLuaFile("cl_init.lua")
|
|
|
|
AddCSLuaFile("shared.lua")
|
|
|
|
resource.AddFile("materials/VGUI/entities/laserPointer.vmt")
|
|
|
|
resource.AddFile("materials/VGUI/entities/laserPointer.vtf")
|
|
|
|
include('shared.lua')
|
|
|
|
|
|
|
|
SWEP.Weight = 8
|
|
|
|
SWEP.AutoSwitchTo = false
|
|
|
|
SWEP.AutoSwitchFrom = false
|
|
|
|
|
|
|
|
SWEP.Receiver = nil
|
|
|
|
SWEP.Pointing = false
|
|
|
|
|
|
|
|
function SWEP:Initialize()
|
|
|
|
self.Pointing = false
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:Reload()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2009-02-06 19:20:23 +00:00
|
|
|
function SWEP:Equip( newOwner )
|
|
|
|
if(newOwner.LasReceiver && newOwner.LasReceiver:IsValid())then
|
|
|
|
self.Receiver = newOwner.LasReceiver
|
|
|
|
newOwner.LasReceiver = nil
|
|
|
|
newOwner:PrintMessage( HUD_PRINTTALK, "Relinked Sucessfully" )
|
2008-06-14 00:55:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PrimaryAttack()
|
|
|
|
self.Pointing = !self.Pointing
|
|
|
|
self.Weapon:SetNWBool("Active", self.Pointing)
|
|
|
|
if(self.Pointing && self.Receiver && self.Receiver:IsValid())then
|
|
|
|
Wire_TriggerOutput(self.Receiver,"Active",1)
|
|
|
|
else
|
|
|
|
Wire_TriggerOutput(self.Receiver,"Active",0)
|
2009-02-06 19:20:23 +00:00
|
|
|
end
|
2008-06-14 00:55:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:SecondaryAttack()
|
2009-02-06 19:20:23 +00:00
|
|
|
local trace = self.Owner:GetEyeTrace()
|
2008-06-14 00:55:20 +00:00
|
|
|
|
|
|
|
if (trace.Entity:GetClass() == "gmod_wire_las_reciever") then
|
|
|
|
self.Receiver = trace.Entity
|
2009-02-06 19:20:23 +00:00
|
|
|
self.Owner:PrintMessage( HUD_PRINTTALK, "Linked Sucessfully" )
|
2008-06-14 00:55:20 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:Think()
|
|
|
|
if(self.Pointing && self.Receiver && self.Receiver:IsValid())then
|
2009-02-06 19:20:23 +00:00
|
|
|
local point = self.Owner:GetEyeTrace().HitPos
|
2008-06-14 00:55:20 +00:00
|
|
|
Wire_TriggerOutput(self.Receiver, "X", point.x)
|
|
|
|
Wire_TriggerOutput(self.Receiver, "Y", point.y)
|
|
|
|
Wire_TriggerOutput(self.Receiver, "Z", point.z)
|
2009-02-06 19:20:23 +00:00
|
|
|
Wire_TriggerOutput(self.Receiver, "Pos", point)
|
2008-06-14 00:55:20 +00:00
|
|
|
self.Receiver.VPos = point
|
|
|
|
end
|
2009-02-06 19:20:23 +00:00
|
|
|
end
|