Skip to content

Instantly share code, notes, and snippets.

@luihum
Created September 27, 2022 18:06
Show Gist options
  • Save luihum/22bd1ca0c34a2553198493890d02d937 to your computer and use it in GitHub Desktop.
Save luihum/22bd1ca0c34a2553198493890d02d937 to your computer and use it in GitHub Desktop.
minified openloader+
_G._OSVERSION="OpenLoader 0.2EE+"local component=component or require('component')local computer=computer or require('computer')local unicode=unicode or require('unicode')local a=component.list("eeprom")()computer.getBootAddress=function()return component.invoke(a,"getData")end;computer.setBootAddress=function(b)return component.invoke(a,"setData",b)end;local c=component.list("gpu")()local d,e;local f=component.list('screen')()for b in component.list('screen')do if#component.invoke(b,'getKeyboards')>0 then f=b end end;local g=function()end;if c and f then component.invoke(c,"bind",f)d,e=component.invoke(c,"getResolution")component.invoke(c,"setResolution",d,e)component.invoke(c,"setBackground",0x000000)component.invoke(c,"setForeground",0xFFFFFF)component.invoke(c,"fill",1,1,d,e," ")g=function()component.invoke(c,"fill",1,1,d,e," ")end end;local h=1;local function i(j)if c and f then component.invoke(c,"set",1,h,j)if h==e then component.invoke(c,"copy",1,2,d,e-1,0,-1)component.invoke(c,"fill",1,e,d,1," ")else h=h+1 end end end;local function k(l,m)local n,o=component.invoke(l,"open",m)if not n then error(o)end;local p=""repeat local q,o=component.invoke(l,"read",n,math.huge)if not q and o then error(o)end;p=p..(q or"")until not q;component.invoke(l,"close",n)return load(p,"="..m)end;local function r(l,m)local s,o=k(l,m)if s then local t=table.pack(pcall(s))if t[1]then return table.unpack(t,2,t.n)else error(t[2])end else error(o)end end;local function u(v)i("BOOTING")_G.computer.getBootAddress=function()return v.address end;g()r(v.address,v.fpx..v.file)end;i(_OSVERSION)i("Select what to boot:")local w={}for l in component.list("filesystem")do if component.invoke(l,"isDirectory","boot/kernel/")then for x,m in ipairs(component.invoke(l,"list","boot/kernel/"))do w[#w+1]={fpx="boot/kernel/",file=m,address=l}i(tostring(#w).."."..m.." from "..l:sub(1,3))end end;if component.invoke(l,"exists","init.lua")then local y="init.lua"if component.invoke(l,"exists",".osprop")then pcall(function()local z=r(l,".osprop")y=z and z.name or"init.lua"end)end;w[#w+1]={fpx="",file="init.lua",address=l}i(tostring(#w).."."..y.." from "..l:sub(1,3))end end;i("Select os: ")if#w==1 then u(w[1])end;if#w==0 then error("No OS found")while true do computer.pullSignal()end end;while true do local A={computer.pullSignal()}if A[1]=="key_down"then if A[4]>=2 and A[4]<=11 then if w[A[4]-1]then u(w[A[4]-1])else i("Not found!")end end end end;error("System crashed")while true do computer.pullSignal()end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment