Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lua/entities/base_wire_entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ if CLIENT then
end

local function getWireName( ent )
local name = ent:GetNWString("WireName")
local name = ent:GetNW2String("WireName")
if not name or name == "" then return ent.PrintName else return name end
end

Expand Down Expand Up @@ -320,7 +320,7 @@ if CLIENT then

-- Basic legacy GetOverlayText, is no longer used here but we leave it here in case other addons rely on it.
function ENT:GetOverlayText()
local name = self:GetNWString("WireName")
local name = self:GetNW2String("WireName")
if name == "" then name = self.PrintName end
local header = "- " .. name .. " -"

Expand Down
6 changes: 3 additions & 3 deletions lua/entities/gmod_wire_expression2/core/selfaware.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ local function doSetName(self, this, name)
else
if #name > 200 then name = string.sub(name, 1, 200) end
if string.find(name, "[\n\r\"]") then return self:throw("setName name contains illegal characters!") end
if this:GetNWString("WireName") == name then return end
this:SetNWString("WireName", name)
if this:GetNW2String("WireName") == name then return end
this:SetNW2String("WireName", name)
duplicator.StoreEntityModifier(this, "WireName", { name = name })

end
Expand Down Expand Up @@ -181,7 +181,7 @@ e2function string entity:getName()
if this.GetGateName then
return this:GetGateName() or ""
end
return this:GetNWString("WireName", this.PrintName) or ""
return this:GetNW2String("WireName", this.PrintName) or ""
end

local function canSetName(self, this, str)
Expand Down
6 changes: 3 additions & 3 deletions lua/entities/gmod_wire_hudindicator/init.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

Check warning on line 3 in lua/entities/gmod_wire_hudindicator/init.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'

include('shared.lua')

Check warning on line 5 in lua/entities/gmod_wire_hudindicator/init.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'

DEFINE_BASECLASS("base_wire_entity")

Expand Down Expand Up @@ -93,11 +93,11 @@

-- Add name if desired
if (hudaddname) then
self:SetNWString("WireName", huddesc)
elseif (self:GetNWString("WireName") == huddesc) then
self:SetNW2String("WireName", huddesc)
elseif (self:GetNW2String("WireName") == huddesc) then
-- Only remove it if the HUD Description was there
-- because there might be another name on it
self:SetNWString("WireName", "")
self:SetNW2String("WireName", "")
end

-- Adjust inputs accordingly
Expand Down Expand Up @@ -149,13 +149,13 @@
-- Send as string (there should be a way to send colors)
local ainfo = self.AR.."|"..self.AG.."|"..self.AB
local binfo = self.BR.."|"..self.BG.."|"..self.BB
umsg.Start("HUDIndicatorStylePercent", pl)

Check warning on line 152 in lua/entities/gmod_wire_hudindicator/init.lua

View workflow job for this annotation

GitHub Actions / lint

"Deprecated"

Deprecated: Use net messages.
umsg.Short(self:EntIndex())
umsg.String(ainfo)
umsg.String(binfo)
umsg.End()
elseif (hudstyle == 3) then -- Full Circle Gauge
umsg.Start("HUDIndicatorStyleFullCircle", pl)

Check warning on line 158 in lua/entities/gmod_wire_hudindicator/init.lua

View workflow job for this annotation

GitHub Actions / lint

"Deprecated"

Deprecated: Use net messages.
umsg.Short(self:EntIndex())
umsg.Float(self.FullCircleAngle)
umsg.End()
Expand All @@ -172,10 +172,10 @@
if not self.RegisteredPlayers[plyuid] then
self.RegisteredPlayers[plyuid] = { ply = ply, hookhidehud = hookhidehud, podonly = podonly }
-- This is used to check for pod-only status in ClientCheckRegister()
self:SetNWBool( plyuid, util.tobool(podonly) )

Check warning on line 175 in lua/entities/gmod_wire_hudindicator/init.lua

View workflow job for this annotation

GitHub Actions / lint

"Deprecated"

Deprecated: Use tobool, without the util bit
end

umsg.Start("HUDIndicatorRegister", ply)

Check warning on line 178 in lua/entities/gmod_wire_hudindicator/init.lua

View workflow job for this annotation

GitHub Actions / lint

"Deprecated"

Deprecated: Use net messages.
umsg.Short(eindex)
umsg.String(self.HUDDesc or "")
umsg.Short(self.HUDShowValue)
Expand All @@ -193,7 +193,7 @@
end

function ENT:UnRegisterPlayer(ply)
umsg.Start("HUDIndicatorUnRegister", ply)

Check warning on line 196 in lua/entities/gmod_wire_hudindicator/init.lua

View workflow job for this annotation

GitHub Actions / lint

"Deprecated"

Deprecated: Use net messages.
umsg.Short(self:EntIndex())
umsg.End()
self.RegisteredPlayers[ply:UniqueID()] = nil
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/gmod_wire_indicator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
end

if CLIENT then
local color_box_size = 64

Check warning on line 21 in lua/entities/gmod_wire_indicator.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: color_box_size
function ENT:GetWorldTipBodySize()
return 400,80
end
Expand All @@ -40,7 +40,7 @@
end

local diff = self.b - self.a
local len = math.abs(self.b) - math.abs(self.a)

Check warning on line 43 in lua/entities/gmod_wire_indicator.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: len
local step = diff / 50

local find_selected = nil
Expand Down Expand Up @@ -113,7 +113,7 @@
-- Percent
local factor = math.Clamp((self.value-self.a)/(self.b-self.a), 0, 1)
local color_text = string.format("%s (%d%%)",math.Round(self.value,2),factor*100)
local w,h = surface.GetTextSize(color_text)

Check warning on line 116 in lua/entities/gmod_wire_indicator.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: w
draw.DrawText( color_text, "GModWorldtip", pos.center.x + 40, pos.min.y + pos.edgesize + h, color_white, TEXT_ALIGN_RIGHT )

-- Slider
Expand Down Expand Up @@ -199,7 +199,7 @@
Model = Model, frozen = frozen, nocollide = nocollide },
a, ar, ag, ab, aa, b, br, bg, bb, ba )
if IsValid(ent) then
ent:SetNWString("WireName", name)
ent:SetNW2String("WireName", name)
duplicator.StoreEntityModifier( ent, "WireName", { name = name } )
end
return ent
Expand Down
2 changes: 2 additions & 0 deletions lua/weapons/gmod_tool/stools/wire_debugger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ if ( CLIENT ) then
language.Add( "Tool_wire_debugger_showports", "Show overlay of ports in HUD" )
language.Add( "Tool_wire_debugger_orientvertical", "Orient the Inputs/Outputs Vertically" )
TOOL.Information = { "left", "right", "reload" }

WireToolSetup.setToolMenuIcon("icon16/script_code.png")
end
if SERVER then
util.AddNetworkString("WireDbgCount")
Expand Down
87 changes: 47 additions & 40 deletions lua/weapons/gmod_tool/stools/wire_namer.lua
Original file line number Diff line number Diff line change
@@ -1,61 +1,68 @@
TOOL.Category = "Tools"
TOOL.Name = "Namer"
TOOL.Command = nil
TOOL.ConfigName = ""
TOOL.Tab = "Wire"

if ( CLIENT ) then
language.Add( "Tool.wire_namer.name", "Naming Tool" )
language.Add( "Tool.wire_namer.desc", "Names components." )
language.Add( "Tool.wire_namer.left", "Set name" )
language.Add( "Tool.wire_namer.right", "Copy name" )
language.Add( "WireNamerTool_name", "Name:" )
TOOL.Information = { "left", "right" }
TOOL.Name = "Namer"
TOOL.Category = "Tools"
TOOL.Tab = "Wire"

if CLIENT then
language.Add("tool.wire_namer.name", "Namer")
language.Add("tool.wire_namer.desc", "Names wire components.")
language.Add("tool.wire_namer.left", "Set name")
language.Add("tool.wire_namer.right", "Copy name")
language.Add("tool.wire_namer.reload", "Reset name")
TOOL.Information = { { name = "left" }, { name = "right" }, { name = "reload" } }

WireToolSetup.setToolMenuIcon("icon16/tag_blue.png")
end

TOOL.ClientConVar[ "name" ] = ""
TOOL.ClientConVar["name"] = ""

local function SetName(ply, ent, data)
if data and data.name then
ent:SetNW2String("WireName", data.name)
duplicator.StoreEntityModifier(ent, "WireName", data)
else
local name = ent:GetNW2String("WireName", false)

if name then
ent:SetNW2String("WireName", nil)
end

local function SetName( Player, Entity, Data )
if ( Data and Data.name ) then
Entity:SetNWString("WireName", Data.name)
duplicator.StoreEntityModifier( Entity, "WireName", Data )
duplicator.ClearEntityModifier(ent, "WireName")
end
end
duplicator.RegisterEntityModifier( "WireName", SetName )

duplicator.RegisterEntityModifier("WireName", SetName)

function TOOL:LeftClick(trace)
if (not trace.Entity:IsValid()) then return end
if (CLIENT) then return end
if (not trace.Entity.IsWire) then return end
local ent = trace.Entity
if not ent:IsValid() or not ent.IsWire then return end
if CLIENT then return true end

local name = self:GetClientInfo("name")

//trace.Entity:SetNWString("WireName", name)

//made the WireName duplicatable entmod (TAD2020)
SetName( Player, trace.Entity, {name = name} )
SetName(nil, ent, { name = name })

return true
end


function TOOL:RightClick(trace)
if (not trace.Entity:IsValid()) then return end
if (CLIENT) then return end
local ent = trace.Entity
if not ent:IsValid() or not ent.IsWire then return end
if CLIENT then return true end

local name = trace.Entity:GetNWString("WireName")
if (not name) then return end
WireLib.SetConvar(self:GetOwner(), "wire_namer_name", ent:GetNW2String("WireName"))

WireLib.SetConvar(self:GetOwner(), "wire_namer_name", name)
return true
end

function TOOL:Reload(trace)
local ent = trace.Entity
if not ent:IsValid() or not ent.IsWire then return end
if CLIENT then return true end

function TOOL.BuildCPanel(panel)
panel:AddControl("Header", { Text = "#Tool.wire_namer.name", Description = "#Tool.wire_namer.desc" })
SetName(nil, ent, {})

panel:AddControl("TextBox", {
Label = "#WireNamerTool_name",
Command = "wire_namer_name",
MaxLength = "20"
})
return true
end

function TOOL.BuildCPanel(panel)
panel:TextEntry("Name", "wire_namer_name")
end
Loading