ay i wanted to use the hud from wire debugger tool but i can only make it move from the top left corner with guns.. can someone help me to set it to find a class so it can automatlly open the hud when it found it? here's the code i have so far... maybe im missing some of it..
Code:
local Components = {}
local UpdateLineCount
local dbg_line_cache
local function IsWire(entity) --try to find out if the entity is wire
if (WireLib.HasPorts(entity)) then return true end
return false
end
local function Test(trace)
if (ents.FindByClass("class")) then return end
if (!trace.Entity:IsValid()) then return end
if (!IsWire(trace.Entity)) then return end
if (CLIENT) then return true end
local ply = self:GetOwner()
Components[ply] = Components[ply] or {}
for k,cmp in ipairs(Components[ply]) do
if (cmp == trace.Entity) then return end
end
table.insert(Components[ply], trace.Entity)
return true
end
if (CLIENT) then
local dbg_lines = {}
local dgb_orient_vert = false
local BoxWidth = 300
local LastBoxUpdate = 0
local function DebuggerDrawHUD()
local dbginfo = ""
if not next(dbg_lines) then return end
--setup the font
surface.SetFont("Default")
--buid the table of entries
local Line_Count = 0
local ColorType = 0
local Entries = {}
for _, Line in pairs(dbg_lines) do
local CurEntry = {}
CurEntry.Lines = {}
local ExplodeLines = string.Explode("\n", Line)
for Index, ExplodeLine in ipairs(ExplodeLines) do --break it into multible lines for 1 entry
if(string.Trim(ExplodeLine) != "") then
local XPos = 0
if(Index > 1) then
if dgb_orient_vert then --if the string is not the first and it is vertical, line it up acordingly
if(string.Trim(ExplodeLine) == "OUT:" or string.Trim(ExplodeLine) == "IN:") then
XPos = 17
else
XPos = 42
end
else --if the string is not the first and it is not vertical, line it up with the IN on the first line
if(CurEntry.Lines[1].LineText and string.find(CurEntry.Lines[1].LineText,"IN:")) then
local TextPos = string.find(CurEntry.Lines[1].LineText,"IN:")-1
XPos = surface.GetTextSize( string.Left(CurEntry.Lines[1].LineText, TextPos) )
end
end
end
local TrimLine = {
LineText = string.Trim(ExplodeLine),
OffsetPos = { XPos, Line_Count*14 } --move the next text down some for each line
}
table.insert(CurEntry.Lines, TrimLine )
Line_Count = Line_Count+1
end
end
--set the color
if(ColorType == 0) then
CurEntry.TextColor = Color(255,255,255)
else
CurEntry.TextColor = Color(130,255,158)
end
--put it in the table
table.insert(Entries, CurEntry)
--switch the color
ColorType = 1-ColorType
end
--determine the box width every second
if(LastBoxUpdate < CurTime()) then
local LongestWidth = 0
local TextWidth, TextHeight
for EntryIndex, Entry in ipairs(Entries) do
for LineIndex, Line in ipairs(Entry.Lines) do
TextWidth, TextHeight = surface.GetTextSize(string.Trim(Line.LineText))
TextWidth = TextWidth+Line.OffsetPos[1] --offset it with the text's offset
if(TextWidth > LongestWidth) then
LongestWidth = TextWidth
end
end
end
BoxWidth = LongestWidth+16
LastBoxUpdate = CurTime()+1
end
--move the box down if the active weapon is the tool gun
local MoveBox = 0
if(LocalPlayer():IsValid() and LocalPlayer():IsPlayer()) then
if IsValid(LocalPlayer():GetActiveWeapon()) and LocalPlayer():GetActiveWeapon():GetClass() == "none" then
MoveBox = 1
end
else --return if the player is dead or non-existant
return
end
-- TODO: account for larger usage info boxes.
--draw the box
draw****undedBox(8, 2, 2+178*MoveBox, BoxWidth, Line_Count*14+16, Color(50, 50, 50, 128))
--step through all of the entries and their text to print them
for EntryIndex, Entry in ipairs(Entries) do
for LineIndex, Line in ipairs(Entry.Lines) do
draw.Text({
text = string.Trim(Line.LineText) or "",
font = "Default",
pos = { Line.OffsetPos[1]+10, 178*MoveBox+10+Line.OffsetPos[2] },
color = Entry.TextColor
})
end
end
end
hook.Add("HUDPaint", "DebuggerDrawHUD", DebuggerDrawHUD)
net.Receive("WireDbgCount", function(netlen)
for k=net.ReadUInt(16)+1, #dbg_lines do
dbg_lines[k] = nil
end
end)
net.Receive("WireDbg", function(netlen)
dgb_orient_vert = net.ReadBit() != 0
dbg_lines[net.ReadUInt(16)] = net.ReadString()
end)
end
tyvm for your time to help me..