Export realtime game statistics to disk in JSON and other formats.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

-- ___ _ _ _
-- / __| |_ __ _| |_ ___ _ _(_)___
-- \__ \ _/ _` | _/ _ \ '_| / _ \
-- |___/\__\__,_|\__\___/_| |_\___/
--
-- Defines in-game console commands
-- used to control the metrics list
-- and test new metrics.
commands.add_command("stat", "Used to control metrics in Statorio mod\n[add|list|del] ", function(param)
player = game.players[param.player_index]
if not player then return end
if not player.admin then
player.print("Statorio commands are only available to admins")
return
end
argsArr = split(param.parameter, " ")
if argsArr[1] == "list" then
if table_size(global.statorio.metrics) > 0 then
for index, val in pairs(global.statorio.metrics) do
player.print("["..index.."] "..val)
end
else
player.print("No metrics to show")
end
elseif argsArr[1] == "add" then
table.insert(global.statorio.metrics, argsArr[2])
player.print("Added metric ["..table_size(global.statorio.metrics).."]")
elseif argsArr[1] == "del" then
table.remove(global.statorio.metrics, argsArr[2])
player.print("Removed metric ["..argsArr[2].."]")
elseif argsArr[1] == "test" then
if not Fetcher.traverseApiForValues(argsArr[2], function(name, val)
player.print(name..": "..safeString(val))
end)
then
player.print("Error - please check API reference")
end
else
player.print("Try list, add, del or test. For example:\n/stat list")
end
end)