Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- FILENAME: doorController.lua(Startup.lua)
- AUTHOR: Donald R. Valverde (Cavious)
- VERSION: 1.0-BETA
- --]]
- local side = "bottom" --REDSTONE SIDE
- rednet.open("right")
- databaseServer = 22 --CHANGE AS NEEDED FOR SERVER
- term.clear()
- 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 redNetReceive()
- while(true) do
- local id, message, protocol = rednet.receive()
- if(message == ".open") then
- redstone.setOutput(side, true)
- os.sleep(10)
- if(redstone.getOutput(side) == true) then
- redstone.setOutput(side, false)
- end
- elseif(message == ".close") then
- redstone.setOutput(side, false)
- end
- end
- end
- function redNetSend()
- local password = {r = 0, g = 0, b = 0}
- local monOne = peripheral.wrap("monitor_0")
- local monTwo = peripheral.wrap("monitor_1")
- local monThree = peripheral.wrap("monitor_2")
- local monFour = peripheral.wrap("monitor_3")
- monOne.setTextScale(0.5)
- monTwo.setTextScale(0.5)
- monThree.setTextScale(0.5)
- monFour.setTextScale(0.5)
- while(true) do
- monOne.clear()
- monTwo.clear()
- monThree.clear()
- monFour.clear()
- drawImage(monOne, ".background", 1, 1)
- drawImage(monTwo, ".background", 1, 1)
- drawImage(monThree, ".background", 1, 1)
- drawImage(monFour, ".background", 1, 1)
- drawText(monOne, "SUBMIT", 5, 8, colors.orange, colors.white)
- drawText(monTwo, "SUBMIT", 5, 8, colors.orange, colors.white)
- drawText(monThree, "SUBMIT", 5, 8, colors.orange, colors.white)
- drawText(monFour, "SUBMIT", 5, 8, colors.orange, colors.white)
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- if(yPos >= 3 and yPos < 6 and xPos == 3 or xPos == 4) then
- password["r"] = "1"
- --FUNCTION HERE
- elseif(yPos >= 3 and yPos < 6 and xPos == 7 or xPos == 8) then
- password["g"] = "1"
- --FUNCTION HERE
- elseif(yPos >= 3 and yPos < 6 and xPos == 11 or xPos == 12) then
- password["b"] = "1"
- --FUNCTION HERE
- elseif(yPos == 8 and xPos >= 5 and xPos < 11) then
- drawText(monOne, "SUBMIT", 5, 8, colors.yellow, colors.white)
- drawText(monTwo, "SUBMIT", 5, 8, colors.yellow, colors.white)
- drawText(monThree, "SUBMIT", 5, 8, colors.yellow, colors.white)
- drawText(monFour, "SUBMIT", 5, 8, colors.yellow, colors.white)
- rednet.send(databaseServer, "id_door_topside::"..password[r]..password[g]..password[b])
- local id, message, protocol = rednet.receive()
- if(message == ".successful") then
- redstone.setOutput(side, true)
- os.sleep(10)
- if(redstone.getOutput(side) == true) then
- redstone.setOutput(side, false)
- end
- end
- os.sleep(1)
- --FUNCTION HERE
- end
- end
- end
- while(true) do
- parallel.waitForAny(redNetReceive, redNetSend)
- end
Advertisement
Add Comment
Please, Sign In to add comment