Skip to content

Commit 428df3b

Browse files
committed
Use matrix and add start on
1 parent b8bcd36 commit 428df3b

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

lua/entities/gmod_wire_lamp.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if CLIENT then
8484
if IsValid( self.ProjTex ) then
8585
self.ProjTex:Remove()
8686
self.ProjTex = nil
87-
self.LastLampHash = nil
87+
self.LastLampMatrix = nil
8888
end
8989
return
9090
end
@@ -107,14 +107,12 @@ if CLIENT then
107107
projtex:SetPos( lightpos )
108108
projtex:SetAngles( self:LocalToWorldAngles( light_info.Angle or angle_zero ) )
109109

110-
local currentPos = self:GetPos()
111-
local currentAng = self:GetAngles()
112-
local lampHash = currentPos.x + currentPos.y * 17 + currentPos.z * 23 + currentAng.p * 29 + currentAng.y * 31 + currentAng.r * 37
113-
local lastLampHash = self.LastLampHash or 0
114-
if lastLampHash ~= lampHash then
110+
local lampMatrix = self:GetWorldTransformMatrix()
111+
local lastLampMatrix = self.LastLampMatrix or 0
112+
if lastLampMatrix ~= lampMatrix then
115113
projtex:Update()
116114
end
117-
self.LastLampHash = lampHash
115+
self.LastLampMatrix = lampMatrix
118116
end
119117

120118
function ENT:OnRemove()

lua/wire/stools/lamp.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ WireToolSetup.SetupMax(10)
1818

1919
if SERVER then
2020
function TOOL:GetConVars()
21-
return self:GetClientNumber("r"), self:GetClientNumber("g"), self:GetClientNumber("b"), self:GetClientInfo("texture"), self:GetClientNumber("fov"), self:GetClientNumber("distance"), self:GetClientNumber("brightness")
21+
return self:GetClientNumber("r"), self:GetClientNumber("g"), self:GetClientNumber("b"), self:GetClientInfo("texture"), self:GetClientNumber("fov"), self:GetClientNumber("distance"), self:GetClientNumber("brightness"), self:GetClientNumber("on") ~= 0
2222
end
2323

2424
function TOOL:LeftClick_PostMake(ent, ply, trace)
@@ -108,6 +108,7 @@ TOOL.ClientConVar["fov"] = 90
108108
TOOL.ClientConVar["distance"] = 1024
109109
TOOL.ClientConVar["brightness"] = 4
110110
TOOL.ClientConVar["model"] = "models/lamps/torch.mdl"
111+
TOOL.ClientConVar["on"] = 1
111112

112113
function TOOL:RightClick(trace)
113114
if CLIENT then return true end
@@ -141,6 +142,10 @@ function TOOL.BuildCPanel(panel)
141142
combobox:AddChoice("Rope", "rope")
142143
combobox:AddChoice("Weld", "weld")
143144
combobox:AddChoice("None", "none")
145+
146+
local startOn = panel:CheckBox("Start On", "wire_lamp_on")
147+
startOn:SetTooltip("If checked, the lamp will be on when spawned.")
148+
144149
panel:ColorPicker("Color", "wire_lamp_r", "wire_lamp_g", "wire_lamp_b")
145150

146151
local matselect = panel:MatSelect("wire_lamp_texture", nil, true, 0.33, 0.33)

0 commit comments

Comments
 (0)