Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This is a Computercraft Security System, made by
- FiMa_Coders. You are free to use the code wherever
- you want in your builds, but you are not allowed
- change the code in any way, except for the things
- that are marked "CHANGABLE".
- ]]
- -- Determine where the modem is. peripheral.wrap ("monitor_2")
- monitorSide = nil
- print("Looking for monitor,")
- if peripheral.isPresent("left") and peripheral.getType("left")=="monitor" then
- monitorSide = "left"
- elseif peripheral.isPresent("right") and peripheral.getType("right")=="monitor" then
- monitorSide = "right"
- elseif peripheral.isPresent("top") and peripheral.getType("top")=="monitor" then
- monitorSide = "top"
- elseif peripheral.isPresent("back") and peripheral.getType("back")=="monitor" then
- monitorSide = "back"
- elseif peripheral.isPresent("bottom") and peripheral.getType("bottom")=="monitor" then
- monitorSide = "bottom"
- elseif peripheral.isPresent("front") and peripheral.getType("front")=="monitor" then
- monitorSide = "front"
- else
- print("No Monitor Found!")
- monitorSide = false
- end
- while monitorSide == false do
- print("No Monitor Found!")
- print("ERROR: "..math.random(1,300))
- sleep(5)
- shell.run("lock")
- end
- os.pullEvent = os.pullEventRaw
- term.clear()
- term.setCursorPos(1,1)
- shell.openTab("lock2")
- sleep(0.1)
- shell.switchTab(2)
- bundleErrorColor = colors.red
- bundleSuccessColor = colors.lime
- m = peripheral.wrap( tostring(monitorSide) )
- m.clear()
- m.setTextScale(0.5)
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- load = fs.open("Config", "r")
- code,autoReset,waitTime,redstoneSide = unpack(textutils.unserialize(load.readAll()))
- load.close()
- inp = {}
- sPos = 4
- function mGUI()
- gui = {
- [[ ?John Dowe ]],
- [[ Security INC. ]],
- [[ +-----------+ ]],
- [[ | | ]],
- [[ +---+---+---+ ]],
- [[ | 1 | 2 | 3 | ]],
- [[ | 4 | 5 | 6 | ]],
- [[ | 7 | 8 | 9 | ]],
- [[ | ?? | 0 | > | ]],
- [[ +---+---+---+ ]],
- }
- m.setTextColor(colors.red)
- for i = 1,10 do
- m.setCursorPos(1,i)
- if i == 3 then
- m.setTextColor(colors.white)
- end
- m.write(gui[i])
- end
- m.setCursorPos(3,9)
- m.setBackgroundColor(colors.red)
- m.write(" >< ")
- m.setCursorPos(11,9)
- m.setBackgroundColor(colors.lime)
- m.write(" <> ")
- m.setCursorPos(3,4)
- m.setBackgroundColor(colors.blue)
- m.write(" ")
- end
- function open()
- if autoReset then
- if waitTime == 0 then waitTime = 2 end
- sleep(waitTime)
- rs.setBundledOutput(redstoneSide,0)
- os.reboot()
- else
- m.setBackgroundColor(colors.black)
- m.clear()
- m.setTextScale(5)
- m.setCursorPos(1,1)
- m.write("<")
- ev, side, xPos, yPos = os.pullEvent("monitor_touch")
- rs.setBundledOutput(redstoneSide,0)
- os.reboot()
- end
- end
- function checkInp()
- if #inp == #code then
- for f = 1,#code do
- if inp[f] == code[f] then
- if f == #code then
- m.setCursorPos(3,4)
- m.setBackgroundColor(colors.lime)
- m.write(" WELCOME! ")
- rs.setBundledOutput(redstoneSide,bundleSuccessColor)
- open()
- end
- else
- m.setCursorPos(3,4)
- m.setBackgroundColor(colors.red)
- m.write("WRONG CODE!")
- rs.setBundledOutput(redstoneSide,bundleErrorColor)
- sleep(10)
- os.reboot()
- end
- end
- else
- m.setCursorPos(3,4)
- m.setBackgroundColor(colors.red)
- m.write("WRONG CODE!")
- rs.setBundledOutput(redstoneSide, bundleErrorColor)
- sleep(10)
- os.reboot()
- end
- end
- function input()
- mGUI()
- while true do
- ev, side, xPos, yPos = os.pullEvent("monitor_touch")
- print(xPos..":"..yPos)
- if ev == "monitor_touch" then
- if xPos > 2 and xPos < 6 and yPos == 6 then
- table.insert(inp,1)
- m.setCursorPos(sPos,4)
- m.write("*")
- sPos = sPos+1
- elseif xPos > 6 and xPos < 10 and yPos == 6 then
- table.insert(inp,2)
- m.setCursorPos(sPos,4)
- m.write("*")
- sPos = sPos+1
- elseif xPos > 10 and xPos < 14 and yPos == 6 then
- table.insert(inp,3)
- m.setCursorPos(sPos,4)
- m.write("*")
- sPos = sPos+1
- elseif xPos > 3 and xPos < 5 and yPos == 7 then
- table.insert(inp,4)
- m.setCursorPos(sPos,4)
- m.write("*")
- sPos = sPos+1
- elseif xPos > 7 and xPos < 9 and yPos == 7 then
- table.insert(inp,5)
- m.setCursorPos(sPos,4)
- m.write("*")
- sPos = sPos+1
- elseif xPos > 11 and xPos < 13 and yPos == 7 then
- table.insert(inp,6)
- m.setCursorPos(sPos,4)
- m.write("*")
- sPos = sPos+1
- elseif xPos > 3 and xPos < 5 and yPos == 8 then
- table.insert(inp,7)
- m.setCursorPos(sPos,4)
- m.write("*")
- sPos = sPos+1
- elseif xPos > 7 and xPos < 9 and yPos == 8 then
- table.insert(inp,8)
- m.setCursorPos(sPos,4)
- m.write("*")
- sPos = sPos+1
- elseif xPos > 11 and xPos < 13 and yPos == 8 then
- table.insert(inp,9)
- m.setCursorPos(sPos,4)
- m.write("*")
- sPos = sPos+1
- elseif xPos > 3 and xPos < 5 and yPos == 9 then
- inp = {}
- m.setCursorPos(3,4)
- m.write(" ")
- sPos = 4
- elseif xPos > 7 and xPos < 9 and yPos == 9 then
- table.insert(inp,0)
- m.setCursorPos(sPos,4)
- m.write("*")
- sPos = sPos+1
- elseif xPos > 11 and xPos < 13 and yPos == 9 then
- checkInp()
- end
- end
- end
- end
- input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement