Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --VARIABILI DA POPOLARE
- apiVersion = "1.0"
- progVersion = "v1.0"
- defconLvl = "Defcon 5"
- isEndorOn = false
- lockTrain = false
- sleep = 60
- shell.run("pastebin get ADaQ4War json")
- os.loadAPI("json")
- function updateVars()
- rest = http.get("http://rgbvm.fabrimat.me/~fabrimat/tds.php")
- s = rest.readAll()
- t = json.decode(s)
- defconLvl = t.defcon
- isEndorOn = t.endor
- lockTrain = t.lock_train
- sleep = t.next_sleep
- end
- maxw, maxh = term.getSize()
- halfw = math.floor(maxw/2)
- halfh = math.floor(maxh/2)
- -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
- local function drawPixelInternal(xPos, yPos)
- term.setCursorPos(xPos, yPos)
- term.write(" ")
- end
- local tColourLookup = {}
- for n = 1, 16 do
- tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
- end
- function drawFilledBox(startX, startY, endX, endY, nColour)
- if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
- "number" or type(endY) ~= "number" or
- (nColour ~= nil and type(nColour) ~= "number") then
- error("Expected startX, startY, endX, endY, colour", 2)
- end
- startX = math.floor(startX)
- startY = math.floor(startY)
- endX = math.floor(endX)
- endY = math.floor(endY)
- if nColour then term.setBackgroundColor(nColour) end
- if startX == endX and startY == endY then
- drawPixelInternal(startX, startY)
- return
- end
- local minX = math.min(startX, endX)
- if minX == startX then
- minY = startY
- maxw = endX
- maxh = endY
- else
- minY = endY
- maxw = startX
- maxh = startY
- end
- for x = minX, maxw do for y = minY, maxh do drawPixelInternal(x, y) end end
- end
- function colore(sfumatura) term.setTextColour(sfumatura) end
- function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
- function fineColore() term.setTextColour(colours.white) end
- function fineSfondo() term.setBackgroundColour(colours.black) end
- function titolo(testo)
- maxw, maxh = term.getSize()
- drawFilledBox(1, 1, maxw, 1, colors.yellow)
- term.setCursorPos((maxw - #testo) / 2, 1)
- colore(colors.black)
- term.write(testo)
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function printCentered(text)
- local curx, cury = term.getCursorPos()
- local maxw, maxh = term.getSize()
- term.setCursorPos((maxw - #text) / 2, cury)
- term.write(text)
- term.setCursorPos(curx, cury + 1)
- end
- function drawMain()
- titolo("Tyrian Defense System")
- if(lockTrain) then
- drawFilledBox(halfw - 9, halfh, halfw + 9, halfh + 2, colors.lime)
- term.setCursorPos(1, halfh+1)
- printCentered("Richiesta accesso")
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(1, halfh/2)
- local defconLvls = {}
- defconLvls["Defcon 1"] = colors.red
- defconLvls["Defcon 2"] = colors.yellow
- defconLvls["Defcon 3"] = colors.lime
- defconLvls["Defcon 4"] = colors.cyan
- defconLvls["Defcon 5"] = colors.purple
- colore(defconLvls[defconLvl])
- printCentered(defconLvl)
- term.setCursorPos(1, halfh/2 + 2)
- colore(colors.white)
- if isEndorOn == false then
- printCentered("ENDOR non attivo")
- else
- printCentered("ENDOR attivo")
- end
- maxw, maxh = term.getSize()
- local versionString = "(C) Proclus & Albannach 2021 - " .. progVersion .. " - API " .. apiVersion .. " "
- term.setCursorPos(1, maxh)
- printCentered(versionString)
- end
- function drawMessage(message, background, text)
- clear()
- titolo("Tyrian Defense System")
- term.setBackgroundColor(background)
- term.setTextColor(text)
- term.setCursorPos(1, halfh)
- printCentered(message)
- maxw, maxh = term.getSize()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- local versionString = "(C) Proclus & Albannach 2021 - " .. progVersion .. " - API " .. apiVersion .. " "
- term.setCursorPos(1, maxh)
- printCentered(versionString)
- end
- function requestAuthorization()
- drawMessage("Richiesta accesso in corso", colors.black, colors.white)
- os.sleep(0.5)
- drawMessage("Richiesta accesso in corso.", colors.black, colors.white)
- os.sleep(0.5)
- drawMessage("Richiesta accesso in corso..", colors.black, colors.white)
- os.sleep(0.5)
- drawMessage("Richiesta accesso in corso...", colors.black, colors.white)
- os.sleep(0.5)
- if(isEndorOn) then
- denyAuth()
- else
- allowAuth()
- end
- end
- function denyAuth()
- drawMessage("Accesso negato", colors.black, colors.red)
- os.sleep(10)
- end
- function allowAuth()
- drawMessage("Accesso consentito", colors.black, colors.lime)
- rs.setOutput("back", false)
- os.sleep(30)
- end
- clear()
- updateVars()
- while true do
- if(lockTrain) then
- rs.setOutput("top", true)
- rs.setOutput("back", true)
- else
- rs.setOutput("top", false)
- rs.setOutput("back", false)
- end
- os.startTimer(sleep)
- clear()
- drawMain()
- event, button, x, y = os.pullEvent()
- term.setCursorPos(1, 17)
- if(event == 'mouse_click' and lockTrain) then
- if x >= (halfw - 9) and x <= (halfw + 9) and y <= (halfh + 2) and y >= (halfh) then
- requestAuthorization()
- end
- elseif(event == 'timer') then
- updateVars()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement