View difference between Paste ID: 7F9Nk8jC and rKyWGQbT
SHOW: | | - or go back to the newest paste.
1-
password = 'sense'
1+
--The "password" triggers a redstone signal on the side "redstoneSide" to open a door, "exitProgram" is to exit the program
2
--uncomment the following line if you want to disable program termination. Personally I have had problems with it so I keep it disabled.
3
4
--os.pullEvent() = os.pullEventRaw()
5
password = 'your password here'
6
exitProgram = 'exitProgram'
7
redstoneSide  = 'bottom' --has to be one of the following: 'bottom' 'front' 'top' 'left' 'back' 'right'
8
username = 'your username here'
9
10-
    clearTerm('Julien\'s PC, please don\'t fiddle around!')
10+
--Clears terminal for a new message
11
function clearTerm(x)
12
    term.clear()
13-
        rs.setOutput('bottom', true)
13+
14
    print(x)
15
end
16-
        rs.setOutput('bottom', false)
16+
17
--The main function, asks for a password and compares to the set variables.
18
function enterPassword()
19
    clearTerm(string.format('%s\'s PC, please don\'t fiddle around!',username))
20
    enteredText = io.read()
21
    if enteredText == password then
22
        rs.setOutput(redstoneSide, true)
23
        clearTerm('Welcome')
24
        os.sleep(3)
25
        rs.setOutput(redstoneSide, false)
26
        enterPassword()
27
    elseif enteredText == exitProgram then
28
        clearTerm('Exitting...')
29
        return
30
    else
31
        clearTerm('Please stop')
32
        os.sleep(3)
33
        enterPassword()
34
    end
35
    return
36
end
37
38
enterPassword()