Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- FILENAME: powerSystem.lua(Change to startup in game)
- CREATED BY: Cavious(Donald R. Valverde)
- VERSION: 1.0-ALPHA
- --]]
- sideMain = ""
- sideDebug = ""
- activeTab = "t1"
- monMain = peripheral.wrap(sideMain)
- monDebug = peripheral.wrap(sideDebug)
- rednet.open( "bottom" )
- function drawText(monitor, text, xPos, yPos, backgroundColor, fontColor)
- monitor.setCursorPos(xPos, yPos)
- monitor.setBackgroundColor(backgroundColor)
- monitor.setTextColor(fontColor)
- monitor.write(text)
- end
- function drawImage(monitor, file, xPos, yPos)
- term.redirect(monitor)
- local image = paintutils.loadImage(file)
- paintutils.drawImage(image, xPos, yPos)
- term.native()
- end
- function tabT1()
- drawImage(monMain, ".backgroundT1", 2, 2)
- --ADD BUTTON(MAX of THREE)
- end
- function tabT2()
- drawImage(monMain, ".backgroundT2", 2, 2)
- --ADD BUTTON(MAX of THREE)
- end
- function tabT3()
- drawImage(monMain, ".backgroundT3", 2, 2)
- --ADD BUTTON(MAX of THREE)
- end
- function tabT4()
- drawImage(monMain, ".backgroundT4", 2, 2)
- --ADD BUTTON(MAX of THREE)
- end
- function logData(text)
- local file = fs.open(".db_log", "w")
- file.writeLine(text)
- file.close()
- end
- function pullDatabase(connectionID, password)
- local file = fs.open(".db_passwords", "r")
- local data = file.readAll()
- file.close()
- if (data:match(password)) then
- rednet.send(connectionID, ".successful")
- logData(connectionID..password.."SUCCESS")
- search = false;
- else
- rednet.send(connectionID, ".fail")
- logData(connectionID..password.."FAILED")
- search = false;
- end
- end
- monMain.clear()
- monMain.setTextScale(0.5)
- drawImage(monMain, ".backgroundLeft", 1, 1)
- drawImage(monMain, ".backgroundRight", 20, 1)
- drawText(monMain, "RESTART", 6, 8, colors.yellow, colors.black)
- drawText(monMain, "T1", 15, 2, colors.green, colors.white)
- drawText(monMain, "T2", 15, 3, colors.blue, colors.white)
- drawText(monMain, "T3", 15, 4, colors.red, colors.white)
- drawText(monMain, "T4", 15, 5, colors.orange, colors.white)
- tabT1()
- function touchScreen()
- while(true) do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- if(yPos == 3 and xPos == 16 or yPos == 3 and xPos == 17) then
- activeTab = "t1"
- tabT1()
- elseif(yPos == 4 and xPos == 16 or yPos == 4 and xPos == 17) then
- activeTab = "t2"
- tabT2()
- elseif(yPos == 5 and xPos == 16 or yPos == 5 and xPos == 17) then
- activeTab = "t3"
- tabT3()
- elseif(yPos == 6 and xPos == 16 or yPos == 6 and xPos == 17) then
- activeTab = "t4"
- tabT4()
- elseif(yPos == 8 and xPos >= 6 and xPos < 14) then
- drawText(monMain, "RESTART", 6, 8, colors.orange, colors.black)
- os.sleep(1)
- os.reboot()
- end
- end
- end
- function redNetData()
- while(true) do
- local id, password, protocol = rednet.receive("password")
- pullDatabase(id, password)
- end
- end
- while(true) do
- parallel.waitForAny(touchScreen, redNetData)
- end
Advertisement
Add Comment
Please, Sign In to add comment