Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Made by Bloodmuffin on YoutTube go watch his video--
- --Just wanted too show off Bloodmuffins cool program--
- --I have added some new stuff too--
- -----PREFERENCES/VARIABLES-----
- local speakerSide = "left"
- local doorname = "door1"
- local modemSide = "top"
- local pin = 1234
- local maxtries = 3
- local locktime = 60 --seconds
- local waittotry = 3 --seconds
- local redstoneSide = "right"
- local monitorSide = "front"
- local serverID = 0
- local tries = 0
- local input = ""
- local keypad = {
- --{num,xpos,ypos}
- {1,2,4},
- {2,7,4},
- {3,12,4},
- {4,2,6},
- {5,7,6},
- {6,12,6},
- {7,2,8},
- {8,7,8},
- {9,12,8},
- {0,7,10}
- }
- -----FUNCTIONS-----
- function checkClick(t,x,y)
- for i,v in pairs(t) do
- num,cx,cy = unpack(v)
- if (x >= cx) and (x <= cx + 2) and (y == cy) then
- return true,num
- end
- end
- return false
- end
- function numClick(num)
- monitor.setCursorPos((5 + (string.len(input) * 2)),2)
- input = input .. num
- monitor.write("*")
- if (string.len(input) == 4) then
- if (tostring(pin) == input) then
- monAction("Access Granted")
- speaker.playSound("minecraft:entity.player.levelup")
- doorOpen()
- monReset(true)
- input = ""
- tries = 0
- else
- input = ""
- tries = tries + 1
- if (tries >= maxtries) then
- monReset()
- monitor.setBackgroundColor(colors.red)
- monAction("TERMINAL LOCKED")
- rednet.send(serverID, 3, doorname)
- speaker.playSound("minecraft:entity.villager.hurt")
- sleep(locktime)
- rednet.send(serverID, 0, doorname)
- monReset(true)
- os.reboot()
- end
- monAction("Access Denied")
- rednet.send(serverID, 2, doorname)
- speaker.playSound("minecraft:entity.villager.no")
- sleep(waittotry)
- monReset(true)
- end
- end
- end
- function monAction(mess)
- monitor.setCursorPos(1,1)
- monitor.write(mess)
- end
- function monReset(isClear)
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(1)
- monitor.setCursorPos(1,1)
- if (isClear) then monitor.clearLine() end
- monitor.setCursorPos(5,2)
- monitor.write("_ _ _ _")
- end
- function doorOpen()
- rednet.send(serverID, 1, doorname)
- redstone.setOutput(redstoneSide, true)
- sleep(3)
- rednet.send(serverID, 4, doorname)
- redstone.setOutput(redstoneSide, false)
- end
- -----BEGIN MAIN-----
- rednet.open(modemSide)
- speaker = peripheral.wrap(speakerSide)
- monitor = peripheral.wrap(monitorSide)
- monitor.setTextScale(0.5)
- w,h = monitor.getSize()
- if (w > 15) or (h > 10) then
- error("Monitor size is to big.")
- exit()
- end
- monReset()
- monReset(true)
- monitor.setBackgroundColor(colors.red)
- monitor.setTextColor(colors.black)
- for i,v in pairs(keypad) do
- num,x,y = unpack(v)
- monitor.setCursorPos(x,y)
- monitor.write(" " .. num .. " ")
- end
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- while true do
- event,button,x,y = os.pullEvent("monitor_touch")
- validClick,num = checkClick(keypad,x,y)
- if (validClick) then
- numClick(num)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement