Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Variables
- players = {"King5kyline"}
- open = false
- x, y = term.getSize()
- os.pullEvent = os.pullEventRaw
- --Functions
- function drawAcross(line, char)
- term.setCursorPos(1, line)
- for i = 1, x do
- term.write(char)
- end
- end
- function drawCentered(line, text)
- term.setCursorPos((x - string.len(text))/ 2, line)
- term.write(text)
- end
- function openDoor()
- rs.setOutput("bottom", true)
- sleep(3.0)
- rs.setOutput("bottom", false)
- sleep(0.1)
- end
- function soundAlarm()
- rs.setOutput("top", true)
- sleep(5.0)
- rs.setOutput("top", false)
- sleep(0.1)
- end
- --Body code
- term.clear()
- drawAcross(1, "*")
- drawCentered(2, "Devils House Security System")
- drawAcross(3, "*")
- while true do
- event, p1 = os.pullEvent()
- if event == "player" then
- for i = 1, #players do
- if players[i] == p1 then
- openDoor()
- open = true
- end
- end
- if not open then
- soundAlarm()
- end
- end
- if event == "redstone" then
- openDoor()
- end
- if (event == "key") and (p1 == 16) then
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement