I'm trying to use an old lua addon (not that old, though) that allows you to see and copy info about all clientside entities, I can't find any similar addon that I could use. The client convars, however, aren't working. I don't have much experience with lua at all and I was wondering if I could get some help. I tried running it on garry's mod 13 beta, though to no avail. Any help would be greatly appreciated.
[url]http://www.facepunch.com/showthread.php?t=770769[/url]
[CODE]-----------------------------------------------------------------
-- Usage: --
-- bind key picker2 --
-- Enable/Disable picker. --
-- --
-- bind key +picker2_copy --
-- Copies the highlighted entry to the clipboard. --
-- Hold down, move mouse over label, release. --
-- --
-----------------------------------------------------------------
-- Console Variables: --
-- picker2_centerdist: --
-- How far from the center should labels be drawn? --
-- Default = 16 pixels --
-- --
-- picker2_decimals: --
-- Number of decimals to round to. --
-- Default = 2 --
-- --
-- picker2_box: --
-- Draw boxes around the currently highlighted label? --
-- 0 = never --
-- 1 = while holding the copy button (Default) --
-- 2 = always --
-- --
-----------------------------------------------------------------
-- Version history: --
-- 1.3.0 - Made picker2_decimals fault-tolerant --
-- - Updated for gmod 13 beta --
-- 1.2.1 - Version 1.2 accidentaly required wiremod to work --
-- 1.2.0 - Made label positions a lot more consistent, --
-- if there is a lot of them. --
-- - You can now display PhysObjs/bones of ragdolls. --
-- "picker2" cycles between disabled/ents/bones. --
-- 1.1.0 - Added cvars for decimals and centerdist --
-- Added box around labels. picker2_box 0 to disable --
-- 1.0.0 - First public release, based on ReaperSWE's ver --
-----------------------------------------------------------------
if not CLIENT then return end -- to avoid stupidity
local validEntity = _R.Entity.IsValid
-- configuration is now done via cvars:
picker2_centerdist = CreateClientConVar("picker2_centerdist", 16, true, false)
picker2_decimals = CreateClientConVar("picker2_decimals" , 2, true, false)
picker2_box = CreateClientConVar("picker2_box" , 1, true, false)
-- cache some library functions
local Round = math.Round
local abs = math.abs
local table_insert = table.insert
local sprintf = string.format
local vecformat = "%.2f, %.2f, %.2f"
local function FormatVector(value)
return sprintf(vecformat, value.x, value.y, value.z)
end
local function FormatAngle(value)
return sprintf(vecformat, value.p, value.y, value.r)
end
local function pairs_sortvalues(tbl, criterion)
local crit = criterion and
function(a,b)
return criterion(tbl[a],tbl[b])
end
or
function(a,b)
return tbl[a] < tbl[b]
end
tmp = {}
for k,v in pairs(tbl) do table.insert(tmp,k) end
table.sort(tmp, crit)
local iter, state, index, k = ipairs(tmp)
return function()
index,k = iter(state, index)
if index == nil then return nil end
return k,tbl[k]
end
end
local mode = 0
-- text to be copied to the clipboard
local selected_text = nil
local freeze_labels = false
-- entities for which labels should be shown
local textents = {}
local entstable = {}
hook.Add("EntityRemoved", "picker2", function(ent)
textents[ent] = nil
end)
--local LocalToWorld = FindMetaTable("Entity").LocalToWorld
local ToScreen = _R.Vector.ToScreen
local SetDrawColor = surface.SetDrawColor
local DrawLine = surface.DrawLine
local vec_forward, vec_left, vec_up
local function drawents()
local centerdist, decimals = picker2_centerdist:GetFloat(), math.Clamp(math.floor(picker2_decimals:GetFloat()),0,16)
vecformat = string.format("%%.%df, %%.%df, %%.%df", decimals, decimals, decimals)
selected_text = nil
local entstable = ents.GetAll()
local centerx = ScrW()/2
local centery = ScrH()/2
-- reset the list of labeled entities
if not freeze_labels then textents = {} end
local playerpos = LocalPlayer():GetPos()
local playershootpos = LocalPlayer():GetShootPos()
local trace = LocalPlayer():GetEyeTrace()
local function drawent(entphys, realent, boneindex)
-- skip entities at players' feet, like the player entity itself and some other things servers tend to place.
if entphys:GetPos() == playerpos then return end
local pos = entphys:GetPos()
-- skip entities that are too close to the player, including weapons
if playershootpos:Distance(pos) < 32 then return end
local pos_ToScreen = ToScreen(pos)
-- Don't draw things we can't see.
if not pos_ToScreen.visible then return end
local scrposx,scrposy = pos_ToScreen.x,pos_ToScreen.y
if scrposx < 0 then return end
if scrposy < 0 then return end
if scrposx >= ScrW() then return end
if scrposy >= ScrH() then return end
--pos_center = entphys:LocalToWorld( Vector( 0, 0, 0)):ToScreen() scrposx,scrposy = pos_center.x, pos_center.y
local LocalToWorld = entphys.LocalToWorld
pos_axis = ToScreen(LocalToWorld(entphys, vec_forward))
SetDrawColor( 255, 0, 0, 255 ) DrawLine( pos_axis.x, pos_axis.y, scrposx, scrposy )
pos_axis = ToScreen(LocalToWorld(entphys, vec_left))
SetDrawColor( 0, 255, 0, 255 ) DrawLine( pos_axis.x, pos_axis.y, scrposx, scrposy )
pos_axis = ToScreen(LocalToWorld(entphys, vec_up))
SetDrawColor( 0, 0, 255, 255 ) DrawLine( pos_axis.x, pos_axis.y, scrposx, scrposy )
-- Don't draw labels for things off-center
if abs(scrposx-centerx) > centerdist then return end
if abs(scrposy-centery) > centerdist then return end
if freeze_labels then return end
-- draw labels for this entity
textents[entphys] = { pos, scrposx, scrposy, nil, realent, boneindex or 0 }
end -- function drawent
-- draw axes
for _, ent in ipairs(entstable) do
if mode == 1 then
drawent(ent)
else--if mode == 2 then
i = 0
local phys
while true do
phys = ent:GetPhysicsObjectNum(i)
if not phys or not phys:IsValid() then
if i == 0 then drawent(ent) end
break
end
drawent(phys, ent, i)
if trace.Entity == ent and trace.PhysicsBone == i then textents[phys] = nil end
i = i + 1
end
end
end -- for entstable
-- Always draw labels for the entity the player is looking at.
local traceent = trace.Entity
if validEntity(traceent) and not freeze_labels then
local hasphys = false
if mode == 2 then
local tracephys = traceent:GetPhysicsObjectNum(trace.PhysicsBone)
if tracephys then
hasphys = true
traceent = tracephys
end
end
local pos = traceent:GetPos()
local pos_ToScreen = ToScreen(pos)
local scrposx,scrposy = math.floor(pos_ToScreen.x),math.floor(pos_ToScreen.y)
local localvec = nil
if not freeze_labels then
local localpos = traceent:WorldToLocal(trace.HitPos)
localvec = "Local Position: " .. FormatVector(localpos)
end
if hasphys then
textents[traceent] = { pos, scrposx, scrposy,
Using any outdated file, no matter how old, WILL cause issues.
[URL="http://facepunch.com/showthread.php?t=1254727&highlight=converting+addons+for+free"]Theres a guy who converts the addons for free.[/URL]
[URL="http://coderhire.com/"]Also you can hire someone here.[/URL]
Sorry, you need to Log In to post a reply to this thread.