Created
April 1, 2020 02:19
-
-
Save MCJack123/ca11a2ea3452f1cbc76d919789e8b6a3 to your computer and use it in GitHub Desktop.
UnBIOS ported to MoonScript (test)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- UnBIOS (MoonScript) by JackMacWindows | |
return if _HOST\find "UnBIOS" | |
keptAPIs = bit32: true, bit: true, ccemux: true, config: true, coroutine: true, debug: true, fs: true, http: true, io: true, mounter: true, os: true, periphemu: true, peripheral: true, redstone: true, rs: true, term: true, _HOST: true, _CC_DEFAULT_SETTINGS: true, _CC_DISABLE_LUA51_FEATURES: true, _VERSION: true, assert: true, collectgarbage: true, error: true, gcinfo: true, getfenv: true, getmetatable: true, ipairs: true, loadstring: true, math: true, newproxy: true, next: true, pairs: true, pcall: true, rawequal: true, rawget: true, rawlen: true, rawset: true, select: true, setfenv: true, setmetatable: true, string: true, table: true, tonumber: true, tostring: true, type: true, unpack: true, xpcall: true, turtle: true, pocket: true, commands: true, _G: true | |
_G[v] = nil for _,v in ipairs [k for k in pairs _G when not keptAPIs[k]] | |
_G.term = _G.term.native! | |
_G.http.checkURL = _G.http.checkURLAsync | |
_G.http.websocket = _G.http.websocketAsync | |
delete = os: {"version", "pullEventRaw", "pullEvent", "run", "loadAPI", "unloadAPI", "sleep"}, http: {"get", "post", "put", "delete", "patch", "options", "head", "trace", "listen", "checkURLAsync", "websocketAsync"}, fs: {"complete"} | |
delete.table = {"unpack", "pack"} if not config | |
_G[k][a] = nil for k,v in pairs delete for _,a in ipairs v | |
_G._HOST ..= " (UnBIOS)" | |
-- Set up TLCO | |
_G.term.native = -> | |
_G.term.native = nil | |
term.setBackgroundColor 32768 | |
term.setTextColor 1 | |
term.setCursorPos 1, 1 | |
term.setCursorBlink true | |
term.clear! | |
file = fs.open "/bios.lua", "r" | |
if file == nil | |
term.setCursorBlink false | |
term.setTextColor 16384 | |
term.write "Could not find /bios.lua. UnBIOS cannot continue." | |
term.setCursorPos 1, 2 | |
term.write "Press any key to continue" | |
coroutine.yield "key" | |
os.shutdown! | |
fn, err = loadstring file.readAll!, "@bios.lua" | |
file.close! | |
if fn == nil | |
term.setCursorBlink false | |
term.setTextColor 16384 | |
term.write "Could not load /bios.lua. UnBIOS cannot continue." | |
term.setCursorPos 1, 2 | |
term.write err | |
term.setCursorPos 1, 3 | |
term.write "Press any key to continue" | |
coroutine.yield "key" | |
os.shutdown! | |
setfenv fn, _G | |
fn! | |
os.shutdown! | |
coroutine.yield! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment