44 lines
1021 B
Lua
44 lines
1021 B
Lua
local LOCAL_MANIFEST_PATH = '/trapos/manifest.json';
|
|
|
|
local function readLocalManifest()
|
|
if not fs.exists(LOCAL_MANIFEST_PATH) then return nil end
|
|
local f = fs.open(LOCAL_MANIFEST_PATH, 'r');
|
|
if not f then return nil end
|
|
local data = f.readAll();
|
|
f.close();
|
|
if not data or data == '' then return nil end
|
|
return textutils.unserializeJSON(data);
|
|
end
|
|
|
|
local manifest = readLocalManifest();
|
|
if not manifest then return end
|
|
|
|
local name = manifest.name or 'TrapOS';
|
|
local version = manifest.version or '?';
|
|
local branch = manifest.branch or 'master';
|
|
local isBeta = branch == 'next';
|
|
|
|
local hasColor = term.isColor and term.isColor();
|
|
local previousColor;
|
|
|
|
if hasColor then
|
|
previousColor = term.getTextColor();
|
|
if isBeta then
|
|
term.setTextColor(colors.orange);
|
|
else
|
|
term.setTextColor(colors.lime);
|
|
end
|
|
end
|
|
|
|
if isBeta then
|
|
print(name .. ' v' .. version .. ' [BETA]');
|
|
else
|
|
print(name .. ' v' .. version);
|
|
end
|
|
|
|
if hasColor and previousColor then
|
|
term.setTextColor(previousColor);
|
|
end
|
|
|
|
print();
|