Command parser now can catch exceptions (finally). Cleaned up code
This commit is contained in:
parent
5c097d9fe0
commit
fc64f35512
1 changed files with 18 additions and 10 deletions
26
sv_lsft.txt
26
sv_lsft.txt
|
@ -87,7 +87,7 @@ do
|
||||||
if plys == #find.allPlayers() then timer.remove("displaystats") displayStats() end
|
if plys == #find.allPlayers() then timer.remove("displaystats") displayStats() end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
core:log(log.INFO, "Collecting data, please wait.")
|
core:log(log.INFO, "Collecting data, please wait...")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function hud()
|
local function hud()
|
||||||
|
@ -114,7 +114,9 @@ do
|
||||||
table.insert(modules, core.colors.logo)
|
table.insert(modules, core.colors.logo)
|
||||||
table.insert(modules, "[L-SFT] ")
|
table.insert(modules, "[L-SFT] ")
|
||||||
table.insert(modules, core.colors.info)
|
table.insert(modules, core.colors.info)
|
||||||
table.insert(modules, "\""..i.."\" | "..(v.desc or "No description provided.").."\n")
|
table.insert(modules, "\""..i.."\" | ")
|
||||||
|
table.insert(modules, core.colors.text)
|
||||||
|
table.insert(modules, (v.desc or "No description provided.").."\n")
|
||||||
end
|
end
|
||||||
modules[#modules] = modules[#modules]:sub(1, -2)
|
modules[#modules] = modules[#modules]:sub(1, -2)
|
||||||
print(unpack(modules))
|
print(unpack(modules))
|
||||||
|
@ -130,7 +132,9 @@ do
|
||||||
table.insert(commands, core.colors.logo)
|
table.insert(commands, core.colors.logo)
|
||||||
table.insert(commands, "[L-SFT] ")
|
table.insert(commands, "[L-SFT] ")
|
||||||
table.insert(commands, core.colors.info)
|
table.insert(commands, core.colors.info)
|
||||||
table.insert(commands, "\""..i.."\" | Usage: "..(v.usage or "No usage provided.").."\n")
|
table.insert(commands, "\""..i.."\" | Usage: ")
|
||||||
|
table.insert(commands, core.colors.text)
|
||||||
|
table.insert(commands, (v.usage or "No usage provided.").."\n")
|
||||||
end
|
end
|
||||||
commands[#commands] = commands[#commands]:sub(1, -2)
|
commands[#commands] = commands[#commands]:sub(1, -2)
|
||||||
print(unpack(commands))
|
print(unpack(commands))
|
||||||
|
@ -139,8 +143,8 @@ do
|
||||||
elseif module ~= nil and command ~= nil then
|
elseif module ~= nil and command ~= nil then
|
||||||
if not core.modules[module].commands[command] then core:log(log.ERROR, "Command does not exist in module \""..module.."\"!") return end
|
if not core.modules[module].commands[command] then core:log(log.ERROR, "Command does not exist in module \""..module.."\"!") return end
|
||||||
core:log(log.TEXT, "---------------------------")
|
core:log(log.TEXT, "---------------------------")
|
||||||
core:log(log.INFO, "Usage: "..(core.modules[module].commands[command].usage or "Command: "..command.." (No usage provided)"))
|
core:log(log.INFO, "Usage: ", core.colors.text, (core.modules[module].commands[command].usage or "Command: "..command.." (No usage provided)"))
|
||||||
core:log(log.INFO, "Description: "..(core.modules[module].commands[command].desc or "No description provided."))
|
core:log(log.INFO, "Description: ", core.colors.text, (core.modules[module].commands[command].desc or "No description provided."))
|
||||||
core:log(log.TEXT, "---------------------------")
|
core:log(log.TEXT, "---------------------------")
|
||||||
else
|
else
|
||||||
core:log(log.ERROR, "Universe is broken.")
|
core:log(log.ERROR, "Universe is broken.")
|
||||||
|
@ -160,7 +164,7 @@ do
|
||||||
hud = {
|
hud = {
|
||||||
func = hud,
|
func = hud,
|
||||||
usage = "hud",
|
usage = "hud",
|
||||||
desc = "Toggles the built in Starfall HUD",
|
desc = "Toggles the built in Starfall HUD.",
|
||||||
},
|
},
|
||||||
help = {
|
help = {
|
||||||
desc = "List modules, list commands in a module or gets information about a specific command.",
|
desc = "List modules, list commands in a module or gets information about a specific command.",
|
||||||
|
@ -179,7 +183,7 @@ core.defaultconfig = {
|
||||||
colors = {
|
colors = {
|
||||||
logo = Color(255,200,50),
|
logo = Color(255,200,50),
|
||||||
text = Color(255,255,255),
|
text = Color(255,255,255),
|
||||||
info = Color(50,150,255),
|
info = Color(150,200,255),
|
||||||
warn = Color(255,120,50),
|
warn = Color(255,120,50),
|
||||||
error = Color(255,50,50),
|
error = Color(255,50,50),
|
||||||
},
|
},
|
||||||
|
@ -195,12 +199,14 @@ core.defaultconfig = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
core.colors = {}
|
core.colors = {}
|
||||||
|
|
||||||
core.maxCPU = 0
|
core.maxCPU = 0
|
||||||
core.minNet = net.getBytesLeft()
|
core.minNet = net.getBytesLeft()
|
||||||
core.maxRAM = 0
|
core.maxRAM = 0
|
||||||
|
|
||||||
|
|
||||||
log = {
|
log = {
|
||||||
ERROR=0,
|
ERROR=0,
|
||||||
WARNING=1,
|
WARNING=1,
|
||||||
|
@ -294,7 +300,10 @@ function core:load_modules()
|
||||||
for i, v in pairs(core.modules) do
|
for i, v in pairs(core.modules) do
|
||||||
for commandin, commandthing in pairs(v["commands"]) do
|
for commandin, commandthing in pairs(v["commands"]) do
|
||||||
if command == commandin then
|
if command == commandin then
|
||||||
commandthing.func({unpack(args)})
|
try(
|
||||||
|
function() commandthing.func({unpack(args)}) end,
|
||||||
|
function(err) core:log(log.ERROR, "Error executing command \""..str.."\"!") core:log(log.ERROR, "Reason: "..err["message"]) end
|
||||||
|
)
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -434,4 +443,3 @@ timer.create("RAMCheck", 0.5, 0, function()
|
||||||
core:log(log.ERROR, "RAM usage is critically high! ("..math.round(ramUsed()*100/ramMax()).."% used)")
|
core:log(log.ERROR, "RAM usage is critically high! ("..math.round(ramUsed()*100/ramMax()).."% used)")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue