Files
lz4halyde/release/init.lua
T
2026-06-20 21:21:19 +03:00

2 lines
3.6 KiB
Lua

local a=component.proxy(component.list("gpu")())local b,c=a.getResolution()local function d(a)assert(type(a)=="string","bad argument #1 to 'decompress' (string expected, got "..type(a)..")")local b,c={},1;local d=#a;local e=1;while e<=d do local f=string.byte(a,e)e=e+1;local g=f//16;if g==15 then repeat local a=string.byte(a,e)e=e+1;g=g+a until a<255 end;for d=0,g-1 do b[c+d]=string.char(string.byte(a,e+d))end;c=c+g;e=e+g;if e>d then break end;local d=f&15;local f,g=string.byte(a,e,e+1)local f=f+g*256;e=e+2;if d==15 then repeat local a=string.byte(a,e)e=e+1;d=d+a until a<255 end;d=d+4;for a=0,d-1 do b[c+a]=b[c-f+a]end;c=c+d end;return table.concat(b)end;local function e(a)checkArg(1,a,"string")local b=component.invoke(computer.getBootAddress(),"open",a,"r")local c=""repeat local a=component.invoke(computer.getBootAddress(),"read",b,math.huge or math.maxinteger)c=c..(a or"")until not a;component.invoke(computer.getBootAddress(),"close",b)return assert(load(d(c),"="..a))end;local function f(a)return(a.."\n \n"..debug.traceback())end;function loadthething()local b=false;for a,a in pairs(computer.getArchitectures())do if a=="Lua 5.3"then b=true;break end end;if b then local a,a=computer.setArchitecture("Lua 5.3")if errorMessage then error(errorMessage)end else a.set(1,1,"Required architecture (Lua 5.3) is not supported.")a.set(1,2,"Halting.")while true do computer.pullSignal()end end;e("/halyde/kernel/boot.lua")(e,d)end;a.setBackground(0)a.fill(1,1,b,c," ")local d=computer.pullSignal;local e=computer.beep;local g=computer.shutdown;local h=unicode;local f,i=xpcall(loadthething,f)local j={}if not f then b,c=a.getResolution()local f;local k,l=false,nil;if _G.require then k,l=pcall(function()f=_G.require("log")f.kernel.error("Halyde has crashed!\n"..tostring(i or"unknown error"))end)end;i="A fatal error has occurred.\nHalyde cannot continue.\n \n"..tostring(i or"unknown error"):gsub("\t"," ")if not f then i="WARNING: This error has occured early enough in the boot process that no log entry could be made.\n\n"..i elseif not k then if type(l)=="nil"then l=""else l="\n"..tostring(l)end;i="WARNING: An error has occured when making a log entry for this crash."..l.."\n\n"..i end;local f;if a.getDepth()==1 then f=0 else f=128 end;a.setBackground(f)a.fill(1,1,b,c," ")for a in string.gmatch(i,"([^\n]*)\n?")do table.insert(j,a)end;local function i()a.setForeground(16777215)for b=1,#j do a.set(2,b+1,j[b])end;a.fill(1,c-1,b,1,"")a.fill(1,c,b,1," ")a.setForeground(f)a.setBackground(16777215)a.set(2,c,"🠅 🠄 🠇 🠆 ⏎")a.setForeground(16777215)a.setBackground(f)a.set(4,c," / ")a.set(9,c," / ")a.set(14,c," / ")a.set(19,c," Scroll ")a.set(29,c," Reboot")end;local function f(b,c,d)a.set(math.max(b,1),c,h.sub(d,math.max(2-b,1)))end;local k=0;local l=0;local function m()if l>=#j-c+2 then return end;a.copy(1,2,b,c-3,0,-1)a.fill(1,c-2,b,1," ")local a=j[l+c-2]if type(a)=="string"then f(2-k,c-2,a)end;l=l+1 end;local function n()if l<=0 then return end;a.copy(1,1,b,c-3,0,1)a.fill(1,1,b,1," ")local a=j[l-1]if type(a)=="string"then f(2-k,1,a)end;l=l-1 end;local o=0;for a=1,#j do o=math.max(o,h.len(j[a]))end;local function h()for d=1,#j do local e=d-l+1;if e>0 and e<=c-2 then a.fill(1,e,b,1," ")f(2-k,e,j[d])end end end;local function a()if k>=o-b+2 then return end;k=k+1;h()end;local function b()if k<=0 then return end;k=k-1;h()end;i()e(440,0.2)e(465,0.2)e(440,0.2)e(370,0.5)while true do local c={d()}if c[1]=="key_down"then if c[4]==200 then n()end;if c[4]==208 then m()end;if c[4]==203 then b()end;if c[4]==205 then a()end;if c[4]==28 then g(true)end end;if c[1]=="scroll"then if c[5]>0 then n()else m()end end end end