Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw -- Disable CTRL+T
- function sleep(n) -- seconds
- local clock = os.clock
- local t0 = clock()
- while clock() - t0 <= n do end
- end
- conf = {}
- function main()
- conf.red_side = 'back'
- conf.pause = 1.5
- conf.pw = 'apple'
- conf.keep_open = false
- conf.menu()
- end
- function start()
- while true do
- if conf.keep_open == true then
- redstone.setOutput(conf.red_side, true)
- else redstone.setOutput(conf.red_side, false)
- end
- print("Passwort eingeben or settings")
- local input = io.read()
- if input == conf.pw then
- term.clear()
- print("Passwort korrekt.")
- redstone.setOutput(conf.red_side, true)
- sleep(3)
- redstone.setOutput(conf.red_side, false)
- elseif input == 'settings' then
- print ("Password:")
- local i = io.read()
- if i == conf.pw then
- term.clear()
- conf.menu()
- else
- print("WRONG PW")
- end
- else
- print("Passwort Falsch!")
- end
- end
- end
- function conf.menu()
- print("Doorlocker by John")
- print("Start: 0")
- print("Set Redstone Side: 1")
- print("Set Password: 2")
- print("Set pause_time: 3")
- print("Set keep-open: 4")
- local input = io.read() input = tonumber(input)
- if input == 0 then
- start()
- elseif input == 1 then
- conf.set_red_side()
- elseif input == 2 then
- conf.set_pw()
- elseif input == 3 then
- conf.set_pause_time()
- elseif input == 4 then
- conf.set_keep_open()
- else
- print("ERROR: WRONG INPUT, DU NOOB!")
- end
- end
- function conf.set_red_side()
- print("Set Redstone Side(back, right, left, up)")
- local input = io.read()
- conf.red_side = input
- conf.menu()
- end
- function conf.set_pw()
- print("Set Password:")
- local input = io.read()
- conf.pw = input
- conf.menu()
- end
- function conf.set_pause_time()
- print("Set Pause Time (must be number):")
- local input = io.read() input = tonumber(input)
- conf.pause_time = input
- conf.menu()
- end
- function conf.set_keep_open()
- print("Keep open?")
- print("1: true; 2: false")
- local input = io.read() input = tonumber(input)
- if input == 1 then
- conf.keep_open = true
- elseif input == 2 then
- conf.keep_open = false
- else
- print("ERROR: Only 1 and 2")
- end
- conf.menu()
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement