add get_system_info function

This commit is contained in:
Evgeny
2021-09-01 10:06:43 +03:00
parent a1b6f73221
commit 260ec67225
4 changed files with 43 additions and 8 deletions

View File

@@ -0,0 +1,32 @@
-- name = "System info"
ticks = -1
function on_tick()
-- Update one time per 10 seconds
ticks = ticks + 1
if ticks % 10 ~= 0 then
return
end
ticks = 0
local info = system:get_system_info()
local strings = stringify_table(info)
ui:show_lines(strings)
end
function stringify_table(tab)
local new_tab = {}
for k,v in pairs(tab) do
table.insert(new_tab, capitalize(k):replace("_", " ")..": "..tostring(v))
end
return new_tab
end
function capitalize(string)
return string:gsub("^%l", string.upper)
end