1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-14 04:34:49 +00:00
opus/sys/apps/system/label.lua

50 lines
1.2 KiB
Lua
Raw Normal View History

local UI = require('opus.ui')
local Util = require('opus.util')
2018-12-23 03:11:16 +00:00
local fs = _G.fs
local os = _G.os
2019-01-30 20:11:41 +00:00
local labelTab = UI.Tab {
2018-12-23 03:11:16 +00:00
tabTitle = 'Label',
description = 'Set the computer label',
labelText = UI.Text {
x = 3, y = 2,
value = 'Label'
},
label = UI.TextEntry {
x = 9, y = 2, ex = -4,
limit = 32,
value = os.getComputerLabel(),
accelerators = {
enter = 'update_label',
},
},
grid = UI.ScrollingGrid {
y = 3,
values = {
{ name = '', value = '' },
{ name = 'CC version', value = Util.getVersion() },
{ name = 'Lua version', value = _VERSION },
{ name = 'MC version', value = Util.getMinecraftVersion() },
{ name = 'Disk free', value = Util.toBytes(fs.getFreeSpace('/')) },
{ name = 'Computer ID', value = tostring(os.getComputerID()) },
{ name = 'Day', value = tostring(os.day()) },
},
inactive = true,
columns = {
{ key = 'name', width = 12 },
{ key = 'value' },
},
},
}
function labelTab:eventHandler(event)
if event.type == 'update_label' then
os.setComputerLabel(self.label.value)
self:emit({ type = 'success_message', message = 'Label updated' })
return true
end
end
return labelTab