Added more helper functions

This commit is contained in:
Logan G 2022-03-25 23:46:18 -06:00
parent 78c804b683
commit 8f4f63bfaa
Signed by: logan
GPG key ID: E328528C921E7A7A

View file

@ -270,6 +270,48 @@ function core:log(...)
print(core.colors.logo, "[L-SFT] ", color, unpack(message))
end
function core:logConsole(...)
local args = {...}
local loglevel = args[1]
local message = { unpack(args, 2, #args) }
local color = Color(0,0,0)
if loglevel == log.ERROR then color = core.colors.error
elseif loglevel == log.WARNING then color = core.colors.warn
elseif loglevel == log.INFO then color = core.colors.info
elseif loglevel == log.TEXT then color = core.colors.text
end
printConsole(core.colors.logo, "[L-SFT] ", color, unpack(message))
end
-- Get's a player's entity by searching for it via an inputted string
function core:get_entity(ply)
if type(ply) == "Player" then
return ply
elseif ply == "^" then
return owner()
end
local targets = find.playersByName(ply)
if #targets == 0 or targets == nil then
core:log(log.ERROR, "No targets found!")
return nil
elseif #targets > 1 then
local list = ""
for i, v in pairs(target) do
list = list..v..", "
end
list:sub(1, -2)
core:log(log.ERROR, "Muliple targets found! ("..list..")")
return nil
end
return targets[1]
end
net.receive("LSFT-Config-Read", function(len, ply)
if ply == owner() then
-- Colors settings aren't loaded yet, so use dumb printing method with default colors (Don't ever do this >:c)