Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- password = ''
- side = ''
- waitTime = 0
- etat = 0
- menuSelectedId = 0
- function os.pullEvent() -- Anti Ctrl+T (Terminate)
- local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
- if event == 'terminate' then
- term.clear() -- Clear the screen
- term.setCursorPos(1,1)
- print('Sorry Ctrl+T is disabled.') -- Write
- print('Reboot...') -- Write
- sleep(1) -- Wait
- os.reboot()
- end
- return event, p1, p2, p3, p4, p5
- end
- function restoreEvent() -- Restore Events (disable Anti Ctrl+T)
- function os.pullEvent( _sFilter )
- local event, p1, p2, p3, p4, p5 = os.pullEventRaw( _sFilter )
- if event == 'terminate' then
- term.clear() -- Clear the screen
- term.setTextColor(colors.red) -- Set the color
- print('Terminated.') -- Write
- term.setTextColor(colors.white) -- Set the color
- error() -- Error (quit the program)
- end
- return event, p1, p2, p3, p4, p5
- end
- end
- function menu(menuId, text)
- if menuSelectedId == menuId then
- print('> ' .. text)
- else
- print('- ' .. text)
- end
- end
- function clear()
- term.clear() -- Clear the screen
- term.setCursorPos(1,1)
- end
- function printTR(text)
- w, h = term.getSize() -- Get Size of the screen
- term.setCursorPos(w - #text, 1)
- write(text) -- Write
- end
- function printTM(text)
- local w, h = term.getSize() -- Get Size of the screen
- term.setCursorPos((w - #text) / 2, 1)
- write(text) -- Write
- end
- function printC(text)
- local x, y = term.getSize() -- Get Size of the screen
- term.setCursorPos((x - string.len(text)) / 2, y / 2)
- write(text) -- Write
- end
- function reset()
- clear() -- Execute clear()
- write('Door Security') -- Write
- printTR('MatiIndustry') -- Write in right
- printTM('Controler') -- Write in middle
- w, h = term.getSize() -- Get Size of the screen
- print(string.rep('-', w)) write('\n') -- Write a separator (line of '-')
- end
- while true do
- -- Launch Message
- reset()
- print('This is the first time you launch the controler program.')
- print('Please configure it.')
- os.sleep(2)
- -- Set Password
- repeat
- reset()
- print('Wanted password:')
- print('(must be longer than four characters')
- write('> ')
- passwordTemp = read('*')
- if string.len(passwordTemp) > 4 then
- print('Great !')
- password = passwordTemp
- pass = 1
- elseif string.len(passwordTemp) == 4 then
- print('A bit short but it\'s okay.')
- password = passwordTemp
- pass = 1
- else
- print('It\'s too short !')
- print('It must be longer than four characters !')
- end
- os.sleep(2)
- until password ~= ''
- -- Set side
- repeat
- reset()
- print('Side where is the redstone: ')
- menu(0, 'Top side')
- menu(1, 'Bottom side')
- menu(2, 'Left side')
- menu(3, 'Right side')
- menu(4, 'Front side')
- menu(5, 'Back side')
- event, key = os.pullEvent('key')
- if key == 200 then
- if menuSelectedId > 0 then
- menuSelectedId = menuSelectedId - 1
- end
- elseif key == 208 then
- if menuSelectedId < 5 then
- menuSelectedId = menuSelectedId + 1
- end
- elseif key == 28 then
- if menuSelectedId == 0 then
- print('Great. So we will use top side.')
- side = 'top'
- os.sleep(2)
- elseif menuSelectedId == 1 then
- print('Great. So we will use bbottomack side.')
- side = 'bottom'
- os.sleep(2)
- elseif menuSelectedId == 2 then
- print('Great. So we will use left side.')
- side = 'left'
- os.sleep(2)
- elseif menuSelectedId == 3 then
- print('Great. So we will use right side.')
- side = 'right'
- os.sleep(2)
- elseif menuSelectedId == 4 then
- print('Great. So we will use front side.')
- side = 'front'
- os.sleep(2)
- elseif menuSelectedId == 5 then
- print('Great. So we will use back side.')
- side = 'back'
- os.sleep(2)
- end
- end
- os.sleep(0.1)
- until side ~= ''
- -- Set Opening Time
- repeat
- reset()
- print('Opening time of the door:')
- print('(must be higher than three)')
- waitTimeTemp = tonumber(read())
- if waitTimeTemp > 3 then
- print('Great!')
- waitTime = waitTimeTemp
- pass = 1
- elseif waitTimeTemp == 3 then
- print('Three... It\'s okay but be careful.')
- waitTime = waitTimeTemp
- pass = 1
- else
- print('It\'s too low!')
- print('It must be higher than three!')
- end
- os.sleep(2)
- until waitTime ~= 0
- -- Message
- reset()
- print('Configuration finished.')
- os.sleep(2)
- -- Search for requests
- repeat
- reset()
- print('Searching request from autorised computers... (fake)')
- os.sleep(2)
- until false
- end
- os.reboot() -- Reboot (for security)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement