From d340018aa712ad7f01a496587d620ecba708e2e9 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Sun, 16 Aug 2026 16:59:07 +0300 Subject: [PATCH 1/2] Fix a LOT of leaking globals --- lua/entities/gmod_wire_characterlcd/init.lua | 2 +- lua/entities/gmod_wire_consolescreen/init.lua | 2 +- .../gmod_wire_digitalscreen/cl_init.lua | 18 ++------ lua/entities/gmod_wire_digitalscreen/init.lua | 2 +- .../gmod_wire_egp/lib/egplib/parenting.lua | 2 +- .../gmod_wire_egp/lib/objects/text.lua | 5 +-- .../gmod_wire_egp/lib/objects/wedge.lua | 2 +- lua/entities/gmod_wire_eyepod.lua | 2 +- lua/entities/gmod_wire_fpga/cl_init.lua | 1 - lua/entities/gmod_wire_fpga/init.lua | 22 +++++----- lua/entities/gmod_wire_gpu/cl_init.lua | 2 +- lua/entities/gmod_wire_indicator.lua | 2 +- lua/entities/gmod_wire_interactiveprop.lua | 44 +++++++++---------- lua/entities/gmod_wire_keypad.lua | 1 + lua/entities/gmod_wire_oscilloscope.lua | 2 +- lua/entities/gmod_wire_teleporter.lua | 6 +-- lua/entities/gmod_wire_twoway_radio.lua | 2 +- .../info_wiremapinterface/convert.lua | 2 +- lua/entities/info_wiremapinterface/io.lua | 6 +-- lua/weapons/gmod_tool/stools/wire_adv.lua | 2 +- lua/wire/client/cl_wirelib.lua | 6 +-- lua/wire/client/node_editor/nodeeditor.lua | 16 +++---- lua/wire/client/sound_browser.lua | 1 + lua/wire/gates/entity.lua | 4 +- lua/wire/gates/vector.lua | 4 +- lua/wire/stools/expression2.lua | 4 +- lua/wire/stools/fpga.lua | 8 ++-- 27 files changed, 78 insertions(+), 92 deletions(-) diff --git a/lua/entities/gmod_wire_characterlcd/init.lua b/lua/entities/gmod_wire_characterlcd/init.lua index 1acba99350..dc2d4c3816 100644 --- a/lua/entities/gmod_wire_characterlcd/init.lua +++ b/lua/entities/gmod_wire_characterlcd/init.lua @@ -219,7 +219,7 @@ function ENT:UpdateOverlay() return end - txt = "" + local txt = "" if IsValid(self.User) then txt = "In use by: " .. self.User:Nick() end diff --git a/lua/entities/gmod_wire_consolescreen/init.lua b/lua/entities/gmod_wire_consolescreen/init.lua index 252002559a..5bc8f04984 100644 --- a/lua/entities/gmod_wire_consolescreen/init.lua +++ b/lua/entities/gmod_wire_consolescreen/init.lua @@ -32,7 +32,7 @@ function ENT:UpdateOverlay() return end - txt = "" + local txt = "" if IsValid(self.User) then txt = "In use by: " .. self.User:Nick() end diff --git a/lua/entities/gmod_wire_digitalscreen/cl_init.lua b/lua/entities/gmod_wire_digitalscreen/cl_init.lua index ae6aedef67..02ca193cce 100644 --- a/lua/entities/gmod_wire_digitalscreen/cl_init.lua +++ b/lua/entities/gmod_wire_digitalscreen/cl_init.lua @@ -240,25 +240,13 @@ transformcolor[0] = function(c) -- RGBXXX local crgb = math.floor(c / 1000) local cgray = c - math.floor(c / 1000)*1000 - cb = cgray+28*math.fmod(crgb, 10) - cg = cgray+28*math.fmod(math.floor(crgb / 10), 10) - cr = cgray+28*math.fmod(math.floor(crgb / 100), 10) - - return cr, cg, cb + return cgray+28*math.fmod(crgb, 10), cgray+28*math.fmod(math.floor(crgb / 10), 10), cgray+28*math.fmod(math.floor(crgb / 100), 10) end transformcolor[2] = function(c) -- 24 bit mode - cb = math.fmod(c, 256) - cg = math.fmod(math.floor(c / 256), 256) - cr = math.fmod(math.floor(c / 65536), 256) - - return cr, cg, cb + return math.fmod(c, 256), math.fmod(math.floor(c / 256), 256), math.fmod(math.floor(c / 65536), 256) end transformcolor[3] = function(c) -- RRRGGGBBB - cb = math.fmod(c, 1000) - cg = math.fmod(math.floor(c / 1e3), 1000) - cr = math.fmod(math.floor(c / 1e6), 1000) - - return cr, cg, cb + return math.fmod(c, 1000), math.fmod(math.floor(c / 1e3), 1000), math.fmod(math.floor(c / 1e6), 1000) end transformcolor[4] = function(c) -- XXX return c, c, c diff --git a/lua/entities/gmod_wire_digitalscreen/init.lua b/lua/entities/gmod_wire_digitalscreen/init.lua index 3be26fc1ee..3aca451b9f 100644 --- a/lua/entities/gmod_wire_digitalscreen/init.lua +++ b/lua/entities/gmod_wire_digitalscreen/init.lua @@ -34,7 +34,7 @@ function ENT:UpdateOverlay() return end - txt = "" + local txt = "" if IsValid(self.User) then txt = "In use by: " .. self.User:Nick() end diff --git a/lua/entities/gmod_wire_egp/lib/egplib/parenting.lua b/lua/entities/gmod_wire_egp/lib/egplib/parenting.lua index 67615602bc..c6ea4b7f5f 100644 --- a/lua/entities/gmod_wire_egp/lib/egplib/parenting.lua +++ b/lua/entities/gmod_wire_egp/lib/egplib/parenting.lua @@ -108,7 +108,7 @@ local function GetGlobalPos(self, Ent, index) if obj.parent == -1 then -- Object is parented to the cursor local x, y = 0, 0 if CLIENT then - xy = EGP:EGPCursor( Ent, LocalPlayer() ) + local xy = EGP:EGPCursor( Ent, LocalPlayer() ) x, y = xy[1], xy[2] end diff --git a/lua/entities/gmod_wire_egp/lib/objects/text.lua b/lua/entities/gmod_wire_egp/lib/objects/text.lua index 824790b2ed..c931eaf59c 100644 --- a/lua/entities/gmod_wire_egp/lib/objects/text.lua +++ b/lua/entities/gmod_wire_egp/lib/objects/text.lua @@ -21,7 +21,6 @@ if CLIENT then surface_SetTextPos = surface.SetTextPos surface_DrawText = surface.DrawText surface_SetTextColor = surface.SetTextColor - surface_CreateFont = surface.CreateFont surface_SetFont = surface.SetFont surface_GetTextSize = surface.GetTextSize @@ -48,7 +47,7 @@ function Obj:Draw(ent, drawMat) x = x - (w * ((self.halign%10)/2)) end if (self.valign) then - if (not h) then _,h = surface_GetTextSize( self.text ) end + if (not h) then local _,new_h = surface_GetTextSize( self.text ) h = new_h end y = y - (h * ((self.valign%10)/2)) end @@ -62,7 +61,7 @@ function Obj:Draw(ent, drawMat) x = (w * ((self.halign%10)/2)) end if (self.valign) then - if (not h) then _,h = surface_GetTextSize( self.text ) end + if (not h) then local _,new_h = surface_GetTextSize( self.text ) h = new_h end y = (h * ((self.valign%10)/2)) end diff --git a/lua/entities/gmod_wire_egp/lib/objects/wedge.lua b/lua/entities/gmod_wire_egp/lib/objects/wedge.lua index 9bb3ecea57..d60e18afd9 100644 --- a/lua/entities/gmod_wire_egp/lib/objects/wedge.lua +++ b/lua/entities/gmod_wire_egp/lib/objects/wedge.lua @@ -55,6 +55,6 @@ function Obj:Contains(x, y) x, y = x / self.w, y / self.h if x * x + y * y > 1 then return false end - theta = math.deg(math.atan2(y, x)) + local theta = math.deg(math.atan2(y, x)) return theta <= -self.size or 0 <= theta end diff --git a/lua/entities/gmod_wire_eyepod.lua b/lua/entities/gmod_wire_eyepod.lua index 157ad9d2de..e79d56102b 100644 --- a/lua/entities/gmod_wire_eyepod.lua +++ b/lua/entities/gmod_wire_eyepod.lua @@ -24,7 +24,7 @@ if CLIENT then hook.Add("CreateMove", "WireEyePodEyeControl", function(ucmd) if enabled then - currentAng = ucmd:GetViewAngles() + local currentAng = ucmd:GetViewAngles() if freezePitch then currentAng.p = freezePitch diff --git a/lua/entities/gmod_wire_fpga/cl_init.lua b/lua/entities/gmod_wire_fpga/cl_init.lua index 2ca6e5317d..5891d52a02 100644 --- a/lua/entities/gmod_wire_fpga/cl_init.lua +++ b/lua/entities/gmod_wire_fpga/cl_init.lua @@ -309,7 +309,6 @@ function ENT:ConstructInsideView(viewData) b[3] = math.min(b[3], node.y) b[4] = math.max(b[4], node.y + node.s * FPGANodeSize) end - borderIsLabel = {false,false,false,false} if viewData.Labels then for _, label in pairs(viewData.Labels) do b[1] = math.min(b[1], label.x) diff --git a/lua/entities/gmod_wire_fpga/init.lua b/lua/entities/gmod_wire_fpga/init.lua index 1bd77dfb4b..c897415dde 100644 --- a/lua/entities/gmod_wire_fpga/init.lua +++ b/lua/entities/gmod_wire_fpga/init.lua @@ -34,7 +34,7 @@ end local function getDefaultValues(node) local gate = getGate(node) - values = {} + local values = {} for inputNum, name in pairs(gate.inputs) do local type = getInputType(gate, inputNum) @@ -229,7 +229,7 @@ function ENT:SynthesizeViewData(data) local gate = getGate(node) local amountOfInputs = 0 if gate.compact_inputs then - inputLimit = gate.compact_inputs + local inputLimit = gate.compact_inputs for inputIdx, _ in pairs(node.connections) do inputLimit = math.max(inputLimit, inputIdx + 1) end @@ -402,8 +402,8 @@ function ENT:CompileData(data) value = node.value, } for input, connection in pairs(node.connections) do - fromNode = connection[1] - fromOutput = connection[2] + local fromNode = connection[1] + local fromOutput = connection[2] if not edges[fromNode] then edges[fromNode] = {} end if not edges[fromNode][fromOutput] then edges[fromNode][fromOutput] = {} end @@ -859,8 +859,8 @@ function ENT:Run(changedNodes) local executeLater = false --if input hasnt arrived, send this node to the back of the queue for inputId, connection in pairs(self.NodeGetsInputFrom[nodeId]) do - nodeId2 = connection[1] - outputNum = connection[2] + local nodeId2 = connection[1] + local outputNum = connection[2] --if node hasnt been visited yet and its going to be visited if not nodesVisited[nodeId2] and activeNodes[nodeId2] then @@ -933,7 +933,7 @@ function ENT:CalculateNode(node, nodeId, gate) --compact gates only calculate with connected inputs if gate.compact_inputs then --find connected inputs, and assign current values - activeValues = {} + local activeValues = {} for inputNum, _ in pairs(self.Data.Nodes[nodeId].connections) do table.insert(activeValues, self.Values[nodeId][inputNum]) end @@ -954,8 +954,8 @@ function ENT:Propagate(node, value) if node.connections then for outputNum, connections in pairs(node.connections) do for k, connection in pairs(connections) do - toNode = connection[1] - toInput = connection[2] + local toNode = connection[1] + local toInput = connection[2] --send values to nodes self.Values[toNode][toInput] = value[outputNum] @@ -968,8 +968,8 @@ function ENT:PropagateAndAddToQueue(node, value, nodeQueue, nodesInQueue) if node.connections then for outputNum, connections in pairs(node.connections) do for k, connection in pairs(connections) do - toNode = connection[1] - toInput = connection[2] + local toNode = connection[1] + local toInput = connection[2] --send values to nodes self.Values[toNode][toInput] = value[outputNum] diff --git a/lua/entities/gmod_wire_gpu/cl_init.lua b/lua/entities/gmod_wire_gpu/cl_init.lua index c24d163629..c71b321e84 100644 --- a/lua/entities/gmod_wire_gpu/cl_init.lua +++ b/lua/entities/gmod_wire_gpu/cl_init.lua @@ -381,7 +381,7 @@ function ENT:Draw(flags) -- Draw image from another GPU local videoSource = MonitorLookup[self:EntIndex()] if videoSource then - videoGPU = ents.GetByIndex(videoSource) + local videoGPU = ents.GetByIndex(videoSource) if videoGPU and videoGPU:IsValid() and videoGPU.GPU then videoGPU.GPU.Entity = self videoGPU.GPU:Render( diff --git a/lua/entities/gmod_wire_indicator.lua b/lua/entities/gmod_wire_indicator.lua index 24b01e50bf..f311fc5d22 100644 --- a/lua/entities/gmod_wire_indicator.lua +++ b/lua/entities/gmod_wire_indicator.lua @@ -227,7 +227,7 @@ function MakeWire7Seg( pl, Pos, Ang, Model, a, ar, ag, ab, aa, b, br, bg, bb, ba if not IsValid( wire_indicators[i] ) then break end for y = 1, i-1 do - const = constraint.Weld( wire_indicators[i], wire_indicators[y], 0, 0, 0, true, true ) + constraint.Weld( wire_indicators[i], wire_indicators[y], 0, 0, 0, true, true ) end wire_indicators[i - 1]:DeleteOnRemove( wire_indicators[i] ) --when one is removed, all are. a linked chain end diff --git a/lua/entities/gmod_wire_interactiveprop.lua b/lua/entities/gmod_wire_interactiveprop.lua index 3bc846dfbe..f97ead5a08 100644 --- a/lua/entities/gmod_wire_interactiveprop.lua +++ b/lua/entities/gmod_wire_interactiveprop.lua @@ -230,31 +230,11 @@ function WireLib.GetInteractiveModel( model ) return InteractiveModels[model] end -function WireLib.GetInteractiveWidgetBody( ent, data ) - local body = vgui.Create("DFrame") - - body:SetTitle(data.title) - body:SetSize(data.width, data.height) - body:SetDraggable(false) - body:MakePopup() - body:Center() - - function body:Paint(w, h) - draw.RoundedBox(4, 0, 0, w, h, color_white) - draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(64, 64, 64)) - end - - for id, widget in ipairs( data.widgets ) do - WidgetBuilders[widget.type](ent, widget, body, id) - end - return body -end - InteractiveModels["models/props_c17/furnituresink001a.mdl"] = copyPropUI( "models/props_interiors/bathtub01a.mdl", "Furniture Sink" ) InteractiveModels["models/props_interiors/sinkkitchen01a.mdl"] = copyPropUI( "models/props_interiors/bathtub01a.mdl", "Kitchen Sink" ) InteractiveModels["models/props_wasteland/prison_sink001a.mdl"] = copyPropUI( "models/props_interiors/bathtub01a.mdl", "Prison Sink" ) -WidgetBuilders = { +local WidgetBuilders = { DCheckBox = function(self, data, body, index) local checkbox = vgui.Create("DCheckBox", body) @@ -312,6 +292,26 @@ WidgetBuilders = { } +function WireLib.GetInteractiveWidgetBody( ent, data ) + local body = vgui.Create("DFrame") + + body:SetTitle(data.title) + body:SetSize(data.width, data.height) + body:SetDraggable(false) + body:MakePopup() + body:Center() + + function body:Paint(w, h) + draw.RoundedBox(4, 0, 0, w, h, color_white) + draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(64, 64, 64)) + end + + for id, widget in ipairs( data.widgets ) do + WidgetBuilders[widget.type](ent, widget, body, id) + end + return body +end + function ENT:GetPanel() local data = InteractiveModels[ self:GetModel() ] return WireLib.GetInteractiveWidgetBody(self, data) @@ -386,7 +386,7 @@ end -- UpdateOverlay ---------------------------------------------------- function ENT:UpdateOverlay() - txt = "" + local txt = "" if IsValid(self.User) then txt = "In use by: " .. self.User:Nick() end diff --git a/lua/entities/gmod_wire_keypad.lua b/lua/entities/gmod_wire_keypad.lua index 9595de94a2..8d57317d4d 100644 --- a/lua/entities/gmod_wire_keypad.lua +++ b/lua/entities/gmod_wire_keypad.lua @@ -45,6 +45,7 @@ if CLIENT then local color_red = Color(255, 0, 0) local color_green = Color(0, 255, 0) + local highlight_key, highlight_until function ENT:Draw(flags) self:DrawModel(flags) diff --git a/lua/entities/gmod_wire_oscilloscope.lua b/lua/entities/gmod_wire_oscilloscope.lua index 08eaa0b89c..10b6439332 100644 --- a/lua/entities/gmod_wire_oscilloscope.lua +++ b/lua/entities/gmod_wire_oscilloscope.lua @@ -179,7 +179,7 @@ function ENT:UpdateOverlay() return end - txt = "" + local txt = "" if IsValid(self.User) then txt = "In use by: " .. self.User:Nick() end diff --git a/lua/entities/gmod_wire_teleporter.lua b/lua/entities/gmod_wire_teleporter.lua index fe3098f248..ec02935d66 100644 --- a/lua/entities/gmod_wire_teleporter.lua +++ b/lua/entities/gmod_wire_teleporter.lua @@ -225,7 +225,7 @@ function ENT:Jump_Part2( withangles ) local Dir = (OldPos - self:GetPos()):GetNormalized() if self.UseEffects then -- Effect - effectdata = EffectData() + local effectdata = EffectData() effectdata:SetEntity( self ) effectdata:SetOrigin( self:GetPos() + Dir * math.Clamp( self:BoundingRadius() * 5, 180, 4092 ) ) util.Effect( "jump_in", effectdata, true, true ) @@ -275,7 +275,7 @@ function ENT:Jump_Part2( withangles ) if self.UseEffects then -- Effect in - effectdata = EffectData() + local effectdata = EffectData() effectdata:SetEntity( ent ) effectdata:SetOrigin( self:GetPos() + Dir * math.Clamp( ent:BoundingRadius() * 5, 180, 4092 ) ) util.Effect( "jump_in", effectdata, true, true ) @@ -294,7 +294,7 @@ function ENT:Jump_Part2( withangles ) if self.UseEffects then for _, ent in pairs( self.OtherEntities ) do -- Render the effect on all other entities in the contraption -- Effect in - effectdata = EffectData() + local effectdata = EffectData() effectdata:SetEntity( ent ) effectdata:SetOrigin( self:GetPos() + Dir * math.Clamp( ent:BoundingRadius() * 5, 180, 4092 ) ) util.Effect( "jump_in", effectdata, true, true ) diff --git a/lua/entities/gmod_wire_twoway_radio.lua b/lua/entities/gmod_wire_twoway_radio.lua index 48475c32f8..9a9bbd07fd 100644 --- a/lua/entities/gmod_wire_twoway_radio.lua +++ b/lua/entities/gmod_wire_twoway_radio.lua @@ -51,7 +51,7 @@ function ENT:Think() self.PairID = nil end end -function IsRadio(entity) +local function IsRadio(entity) if IsValid(entity) and entity:GetClass() == "gmod_wire_twoway_radio" then return true end return false end diff --git a/lua/entities/info_wiremapinterface/convert.lua b/lua/entities/info_wiremapinterface/convert.lua index 84c1e4ecd6..677c53cd74 100644 --- a/lua/entities/info_wiremapinterface/convert.lua +++ b/lua/entities/info_wiremapinterface/convert.lua @@ -154,7 +154,7 @@ local g_supportedTypesById = { wireType = "VECTOR4", toHammer = function(_, wireValue) - val = val or {0, 0, 0, 0} + local val = wireValue or {0, 0, 0, 0} local x = tonumber(val[1] or 0) or 0 local y = tonumber(val[2] or 0) or 0 diff --git a/lua/entities/info_wiremapinterface/io.lua b/lua/entities/info_wiremapinterface/io.lua index 3893ed3ff5..4b5c7e05d7 100644 --- a/lua/entities/info_wiremapinterface/io.lua +++ b/lua/entities/info_wiremapinterface/io.lua @@ -294,7 +294,7 @@ local function deturedAcceptInput(this, name, activator, caller, data, ...) errOrResult = tostring(errOrResult or "") if errOrResult ~= "" then - message = caller:FormatString(": Lua error in target AcceptInput:\n Wire input '%s [%s]' -> Hammer output '%s@%s'\n %s", globals.WIRE_NAME, globals.WIRE_TYPE, caller:FormatEntityString(this), name, errOrResult) + local message = caller:FormatString(": Lua error in target AcceptInput:\n Wire input '%s [%s]' -> Hammer output '%s@%s'\n %s", globals.WIRE_NAME, globals.WIRE_TYPE, caller:FormatEntityString(this), name, errOrResult) ErrorNoHaltWithStack(message) end @@ -343,7 +343,7 @@ function ENT:TriggerWireOutputSafe(wireEnt, wireOutputName, wireValue, ...) err = tostring(err or "") if err ~= "" then - message = self:FormatString(": Lua error at Wire output '%s':\n%s", wireOutputName, err) + local message = self:FormatString(": Lua error at Wire output '%s':\n%s", wireOutputName, err) ErrorNoHaltWithStack(message) end @@ -363,7 +363,7 @@ function ENT:TriggerHammerOutputSafe(hammerOutputName, activator, hammerValue, . err = tostring(err or "") if err ~= "" then - message = self:FormatString(": Lua error at Hammer output '%s':\n%s", hammerOutputName, err) + local message = self:FormatString(": Lua error at Hammer output '%s':\n%s", hammerOutputName, err) ErrorNoHaltWithStack(message) end diff --git a/lua/weapons/gmod_tool/stools/wire_adv.lua b/lua/weapons/gmod_tool/stools/wire_adv.lua index 137c12bc40..2b616d45c3 100644 --- a/lua/weapons/gmod_tool/stools/wire_adv.lua +++ b/lua/weapons/gmod_tool/stools/wire_adv.lua @@ -517,7 +517,7 @@ elseif CLIENT then local traceData = util.GetPlayerTrace(LocalPlayer()) traceData.filter = { LocalPlayer(), trace.Entity } traceData.collisiongroup = LAST_SHARED_COLLISION_GROUP - newTrace = util.TraceLine(traceData) + local newTrace = util.TraceLine(traceData) parent = newTrace.Entity if not IsValid(parent) or parent == game.GetWorld() then -- Hit the world, don't update the trace. diff --git a/lua/wire/client/cl_wirelib.lua b/lua/wire/client/cl_wirelib.lua index a8d6911841..9554763b27 100644 --- a/lua/wire/client/cl_wirelib.lua +++ b/lua/wire/client/cl_wirelib.lua @@ -10,8 +10,8 @@ local Wire_DisableWireRender = CreateClientConVar("cl_wire_disablewirerender", 0 WIRE_CLIENT_INSTALLED = 1 -BeamMat = Material("tripmine_laser") -BeamMatHR = Material("Models/effects/comball_tape") +local BeamMat = Material("tripmine_laser") +local BeamMatHR = Material("Models/effects/comball_tape") local scroll, scroll_offset = 0, 0 @@ -74,7 +74,7 @@ local function Wire_Render_Enabled(ent) -- CREATING (Not assigning a value) local variables OUTSIDE of cycle a bit faster local blink = ent_tbl.WireBlinkWire - local start, color, nodes, len, endpos, node, node_ent, last_node_ent, vector_cache + local start, color, nodes, len, endpos, node, node_ent, last_node_ent, vector_cache, width for net_name, wiretbl in pairs(wires) do width = wiretbl.Width diff --git a/lua/wire/client/node_editor/nodeeditor.lua b/lua/wire/client/node_editor/nodeeditor.lua index 8b12f70c06..e39fa9082c 100644 --- a/lua/wire/client/node_editor/nodeeditor.lua +++ b/lua/wire/client/node_editor/nodeeditor.lua @@ -696,7 +696,7 @@ function getInputAmountForNode(node) local gate = getGate(node) local amountOfInputs = 0 if gate.compact_inputs then - inputLimit = gate.compact_inputs + local inputLimit = gate.compact_inputs for inputIdx, _ in pairs(node.connections) do inputLimit = math.max(inputLimit, inputIdx + 1) end @@ -1914,7 +1914,7 @@ function Editor:CreateNode(selectedInMenu, x, y) -- Save state before creating node self:SaveState("Create Node") - node = { + local node = { type = selectedInMenu.type, gate = selectedInMenu.gate, visual = selectedInMenu.visual, @@ -2408,8 +2408,8 @@ function Editor:BeginDrawingConnection(nodeId, inputNum, outputNum, doubleClick) if inputNum then --check if something is connected to this input - node = self.Nodes[nodeId] - Input = node.connections[inputNum] + local node = self.Nodes[nodeId] + local Input = node.connections[inputNum] --Input already connected if Input then @@ -2702,7 +2702,7 @@ function Editor:OpenConstantSetWindow(node, x, y, type) self.ConstantSetString:SetText(node.valueAsString or (node.value.x .. ", " .. node.value.y .. ", " .. node.value.z)) self.ConstantSetString:RequestFocus() self.ConstantSetString.OnEnter = function(pnl) - valid, x, y, z = validateVector(pnl:GetValue()) + local valid, x, y, z = validateVector(pnl:GetValue()) if valid then node.value = Vector(x, y, z) node.valueAsString = pnl:GetValue() @@ -2711,7 +2711,7 @@ function Editor:OpenConstantSetWindow(node, x, y, type) end end self.ConstantSetString.OnChange = function(pnl) - valid, _, _, _ = validateVector(pnl:GetValue()) + local valid, _, _, _ = validateVector(pnl:GetValue()) if valid then pnl:SetTextColor(color_black) else pnl:SetTextColor(invalidColor) end end @@ -2720,7 +2720,7 @@ function Editor:OpenConstantSetWindow(node, x, y, type) self.ConstantSetString:SetText(node.valueAsString or (node.value.x .. ", " .. node.value.y .. ", " .. node.value.z)) self.ConstantSetString:RequestFocus() self.ConstantSetString.OnEnter = function(pnl) - valid, p, y, r = validateVector(pnl:GetValue()) + local valid, p, y, r = validateVector(pnl:GetValue()) if valid then node.value = Angle(p, y, r) node.valueAsString = pnl:GetValue() @@ -2729,7 +2729,7 @@ function Editor:OpenConstantSetWindow(node, x, y, type) end end self.ConstantSetString.OnChange = function(pnl) - valid, _, _, _ = validateVector(pnl:GetValue()) + local valid, _, _, _ = validateVector(pnl:GetValue()) if valid then pnl:SetTextColor(color_black) else pnl:SetTextColor(invalidColor) end end diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index 1c0318cf6e..8d2ac097c6 100644 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -619,6 +619,7 @@ local function Infomenu(parent, node, SoundEmitter, nSoundVolume, nSoundPitch) end local Menu = DermaMenu() + local MenuItem --Copy to clipboard MenuItem = Menu:AddOption("Copy to clipboard", function() diff --git a/lua/wire/gates/entity.lua b/lua/wire/gates/entity.lua index bf56e153ef..4ec019b58b 100644 --- a/lua/wire/gates/entity.lua +++ b/lua/wire/gates/entity.lua @@ -124,9 +124,7 @@ GateActions["entity_applytorq"] = { local phys = ent:GetPhysicsObject() if not IsValid( phys ) then return end if not isvector(vec) then vec = Vector (0, 0, 0) end - if not isvector(offset) then offset = Vector (0, 0, 0) end vec = clamp(vec) - offset = clamp(offset) if vec.x == 0 and vec.y == 0 and vec.z == 0 then return end local tq = vec @@ -1026,7 +1024,7 @@ GateActions["entity_heading"] = { -- Elevation local len = Position:Length() - elevation = 180 / math.pi * math.asin( Position.z / len ) + local elevation = 180 / math.pi * math.asin( Position.z / len ) return bearing, elevation, Angle(bearing,elevation,0) end, diff --git a/lua/wire/gates/vector.lua b/lua/wire/gates/vector.lua index 2bd103650d..6178e50a33 100644 --- a/lua/wire/gates/vector.lua +++ b/lua/wire/gates/vector.lua @@ -547,7 +547,7 @@ GateActions["vector_max"] = { inputs = { "A" , "B" }, inputtypes = { "VECTOR" , "VECTOR" }, outputtypes = { "VECTOR" }, - output = function(gate, A) + output = function(gate, A , B) if not isvector (A) then A = Vector (0, 0, 0) end if not isvector (B) then B = Vector (0, 0, 0) end if A:Length() > B:Length() then return A else return B end @@ -563,7 +563,7 @@ GateActions["vector_min"] = { inputs = { "A" , "B" }, inputtypes = { "VECTOR" , "VECTOR" }, outputtypes = { "VECTOR" }, - output = function(gate, A) + output = function(gate, A , B) if not isvector (A) then A = Vector (0, 0, 0) end if not isvector (B) then B = Vector (0, 0, 0) end if A:Length() < B:Length() then return A else return B end diff --git a/lua/wire/stools/expression2.lua b/lua/wire/stools/expression2.lua index 49bda2bec5..23806fb604 100644 --- a/lua/wire/stools/expression2.lua +++ b/lua/wire/stools/expression2.lua @@ -948,7 +948,7 @@ if CLIENT then percent2 = p2 and math.Clamp(p2,0,100) or nil end - function DrawTextOutline(text, font, x, y, color, xalign, yalign, bordercolor, border) + local function DrawTextOutline(text, font, x, y, color, xalign, yalign, bordercolor, border) for i = 0, 8 do draw.SimpleText(text, font, x + border * math.sin(i * math.pi / 4), y + border * math.cos(i * math.pi / 4), bordercolor, xalign, yalign) end @@ -1083,7 +1083,7 @@ elseif CLIENT then end local prevmodel, prevvalid -function validModelCached(model) +local function validModelCached(model) if model ~= prevmodel then prevmodel = model prevvalid = util.IsValidModel(model) diff --git a/lua/wire/stools/fpga.lua b/lua/wire/stools/fpga.lua index 5fe2eee49d..dac20282e9 100644 --- a/lua/wire/stools/fpga.lua +++ b/lua/wire/stools/fpga.lua @@ -269,10 +269,10 @@ if CLIENT then ------------------------------------------------------------------------------ -- Tool screen ------------------------------------------------------------------------------ - tool_program_name = "" - tool_program_start = 0 - tool_program_size = 0 - tool_program_bytes = "" + local tool_program_name = "" + local tool_program_start = 0 + local tool_program_size = 0 + local tool_program_bytes = "" function FPGASetToolInfo(name, size, last_bytes) if #name > 18 then tool_program_name = name:sub(1,15) .. "..." From 6b0a329f98d905768fbba7813eed2bbce3413f03 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Sun, 16 Aug 2026 16:59:40 +0300 Subject: [PATCH 2/2] Remove WireLib.hud_debug Useless --- lua/entities/gmod_wire_graphics_tablet.lua | 1 - lua/wire/client/cl_wirelib.lua | 7 ------- 2 files changed, 8 deletions(-) diff --git a/lua/entities/gmod_wire_graphics_tablet.lua b/lua/entities/gmod_wire_graphics_tablet.lua index 92e02bff10..746a5b23d2 100644 --- a/lua/entities/gmod_wire_graphics_tablet.lua +++ b/lua/entities/gmod_wire_graphics_tablet.lua @@ -49,7 +49,6 @@ if CLIENT then if ent:IsValid() then local dist = trace.Normal:Dot(trace.HitNormal)*trace.Fraction*-16384 dist = math.max(dist, trace.Fraction*16384-ent:BoundingRadius()) - --WireLib.hud_debug(""..dist, true) if dist < self.workingDistance and ent == self.GPU.Entity then local cpos = WorldToLocal(trace.HitPos, Angle(), pos, ang) diff --git a/lua/wire/client/cl_wirelib.lua b/lua/wire/client/cl_wirelib.lua index 9554763b27..733fc30a23 100644 --- a/lua/wire/client/cl_wirelib.lua +++ b/lua/wire/client/cl_wirelib.lua @@ -238,13 +238,6 @@ function Derma_QueryNoBlur(...) return panel end -function WireLib.hud_debug(text, oneframe) - hook.Add("HUDPaint","wire_hud_debug",function() - if oneframe then hook.Remove("HUDPaint", "wire_hud_debug") end - draw.DrawText(text, "Trebuchet24", 10, ScrH() / 5, color_white, 0) - end) -end - local old_renderhalos = WireLib.__old_renderhalos or hook.GetTable().PostDrawEffects.RenderHalos WireLib.__old_renderhalos = old_renderhalos if old_renderhalos ~= nil then