Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fileTableGet(path)
- if fs.exists(path) then
- local file = io.open(path, "r")
- local lines = {}
- local i = 1
- local line = file:read("*l")
- while line ~= nil do
- lines[i] = line
- line = file:read("*l")
- i = i + 1
- end
- file:close()
- return lines
- end
- return {}
- end
- function fileLineGet(path, line)
- if fs.exists(path) then
- local lines = fileTableGet(path)
- return lines[line]
- end
- return ""
- end
- local split = function(str, pat) local t = {} local fpat = "(.-)"..pat local last_end = 1 local s, e, cap = str:find(fpat, 1) while s do if s ~= 1 or cap ~= "" then table.insert(t,cap) end last_end = e+1 s, e, cap = str:find(fpat, last_end) end if last_end <= #str then cap = str:sub(last_end) table.insert(t, cap) end return t end
- local lines = fileTableGet("/PSAV/reports/logs.txt", "r")
- logfilename = lines[#lines]
- --Für den Hintergrund
- scantext = [[
- --- --- -- - -
- | | | | |\ |
- --- | |--| | \ |
- | | | | | \ |
- --- --- - - - --
- ]]
- function bg(pcount)
- term.setBackgroundColour( colors.green )
- term.clear()
- term.setTextColour(colors.cyan)
- term.setCursorPos(2,2)
- print("PSAV - BETA")
- term.setCursorPos(51,1)
- term.setBackgroundColour( colors.red )
- print("x")
- term.setBackgroundColour( colors.green )
- term.setCursorPos(2,5)
- term.setTextColour(colors.yellow)
- print(scantext)
- term.setCursorPos(37,2)
- if pcount == 0 then
- term.setTextColour(colors.lime)
- print("Safe!")
- term.setTextColour(colors.white)
- else
- term.setTextColour(colors.orange)
- write("Problems!\(")
- write(problemcount)
- write("\)")
- end
- term.setTextColour(colors.cyan)
- term.setCursorPos(1,19)
- write("Settings")
- end
- os.loadAPI("PSAV/api/border")
- term.setCursorPos(49,1)
- print("x")
- -- problem/infektion
- problemcount = fileLineGet("/PSAV/data/problem", 4)
- term.setCursorPos(3,2)
- problemcount = 0
- linecount = 0
- okay = false
- line = "blah"
- while line ~= nil do
- line = fileLineGet(logfilename, linecount + 1)
- if line ~= nil then
- linecount = linecount + 1
- res = split(line, "\t")
- if res[3] == "problem" then
- problemcount = problemcount + 1
- end
- end
- end
- --klicken
- geklickt = false
- fileMenu = {"open", "save as", "exit"}
- --local Menu = {fileMenu, EditMenu}
- bg(problemcount)
- while geklickt == false do
- event, knopf, x, y = os.pullEvent("mouse_click")
- --Klicken auf >Probleme<
- if (x >= 37) and (x < 51) and (y == 2) then
- geklickt = true
- shell.run("/PSAV/details")
- end
- --Klicken auf PSAV
- if (x >= 2) and (x < 5) and (y == 2) then
- end
- --Klicken auf X / Beenden
- if (x == 51) and (y == 1) then
- geklickt = true
- term.setBackgroundColour( colors.black )
- term.clear()
- term.setCursorPos(1,1)
- shell.run()
- end
- --Klicken auf SCAN
- if (x >= 3) and (x <= 21) and (y >= 6) and (y <= 10) then
- shell.run("/PSAV/scan")
- geklickt = true
- end
- --Klicken auf Settings
- if (x >= 1) and (x <= 8) and (y == 19) then
- shell.run("/PSAV/settings")
- geklickt = true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment