Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --tArgs = {...}
- --if #tArgs ~= 3 or tArgs[1] ~= "startup" then
- --printError("USE: shell.run['LogCraft','startup','config','logs']")
- --os.sleep(3)
- -- os.reboot()
- --error("API ERROR",2)
- --end
- a = "Doodle/logs.txt"
- if printf then print = printf end
- if writef then write = writef end
- if readf then read = readf end
- --Compiler \/
- function complile(filename)
- ----------------------
- file = fs.open(filename,"r")
- returndata = {} word = {} word2 = {}
- data = {}
- for str in string.gmatch(file.readAll(), "([^%s+])") do
- data[#data + 1] = str
- end
- file.close() i = 1
- if data[1] == "{" then
- while true do
- if num == nil then
- i = i + 1
- else
- i = i + num + 1
- num = nil
- end
- -- Datei <--
- if data[i] == "{" then
- printError("Dont use '{' , '}' , '=' or ';' as string")
- elseif data[i] == "}" then
- return returndata
- elseif #data < i then
- printError("'}' expected at line "..#returndata + 2)
- return
- elseif data[i] == "=" then
- for o=i + 1,#data do
- if data[o] == "=" or data[o] == "}" then
- printError("';' expected at line "..#returndata + 2)
- return
- elseif #word < 1 then
- printError("Unable to complier at line "..#returndata + 2)
- return
- elseif data[o] == ";" then
- if #word2 < 1 then
- printError("Unable to complier at line "..#returndata + 2)
- return
- end
- returndata[#returndata + 1] = {table.concat(word),table.concat(word2)}
- word = {} word2 = {}
- num = o - i
- break
- else
- word2[#word2 + 1] = data[o]
- end
- end
- elseif data[i] == ";" or data[i] == "}" then
- printError("'=' expected at line "..#returndata + 2)
- return
- else
- word[#word + 1] = data[i]
- end
- --
- end
- else
- printError("'{' at line 1")
- return
- end
- ---------------------
- return
- end
- -- Compiler /\
- local function reset()
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- end
- local function rebootscreen()
- reset()
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.clear()
- print("LogCraft 0.1")
- term.setCursorPos(1,2)
- print("by Phins")
- paintutils.drawLine(1,19,51,19,colors.white)
- term.setTextColor(colors.black)
- for i=1,20 do
- term.setCursorPos(1,19)
- write((i*5).."% Loading")
- os.sleep(0.01)
- end
- reset()
- end
- function setupconfig()
- if not fs.exists(tArgs[2]) then --EDIT
- file = fs.open(tArgs[2],"w") --EDIT
- file.write("{\n") file.write("logloader = false;\n")
- file.write("rebootscreen = false;\n")
- file.write("txtlog = false;\n")
- file.write("startlog = true;\n") file.write("}")
- file.close()
- end
- local data = complile(tArgs[2]) --EDIT
- logload = data[1][2] rebscreen = data[2][2]
- txtlog = data[3][2] stlog = data[4][2]
- end
- --|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-x
- local log = {} --x
- --x
- local function loadLog() --x
- local file = fs.open(a, "r") --EDIT --x
- if file then --x
- log = {} --x
- local line = file.readLine() --x
- while line do --x
- table.insert(log, line) --x
- line = file.readLine() --x
- end --x
- file.close() --x
- end --x
- end --x
- --x
- local function saveLog() --x
- local file = fs.open(a, "w") --EDIT --x
- for i=1,#log do --x
- file.write(log[i].."\n") --x
- end --x
- file.close() --x --x
- end --x
- --x
- function addlog(s) --x
- table.insert(log, s) --x
- saveLog() --x
- end --x
- --x
- function dellog() --x
- list = fs.list("Doodle") --Edit --x
- for i=1,#list do --x
- if list[i] == a then --EDIT --x
- fs.open(a,"w") --EDIT --x
- end --x
- end --x
- end --x
- --x
- local function startlog() --x
- addlog("\n <-----\n")--x
- addlog("###############################") --x
- addlog("######## Log opened #########") --x
- addlog("###############################") --x
- addlog("Computer Details") --x
- addlog("++++++++++++++++++++++++++++++++++++") --x
- if term.isColor() then --x
- addlog("Type: Advanced") --x
- else --x
- addlog("Type: Normal") --x
- end --x
- addlog("ID: "..os.getComputerID()) --x
- if os.getComputerLabel() then --x
- addlog("Label: "..os.getComputerLabel()) --x
- else --x
- addlog("Label: Nil") --x
- end --x
- addlog("Version: "..os.version()) --x
- addlog("Time: "..os.time()) --x
- addlog("++++++++++++++++++++++++++++++++++++\n") --x
- end --x
- --x
- --|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-x
- setupconfig()
- if logload == "true" then loadLog() end
- if rebscreen == "true" then rebootscreen() end
- if stlog == "true" then startlog() end
- if txtlog == "true" then
- local printf = print
- local writef = write
- local readf = read
- function print(strg)
- x,y = term.getCursorPos()
- addlog("Print: "..strg)
- printf(strg)
- end
- function write(strg)
- x,y = term.getCursorPos()
- addlog("Write: "..strg)
- writef(strg)
- end
- function read(strg)
- local inp = readf(strg)
- if inp then
- addlog("READ: "..inp)
- end
- return inp
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement