SHOW:
|
|
- or go back to the newest paste.
| 1 | - | -- Derp Password Door thing v0.1 |
| 1 | + | -- H4X Security Door v1.0 |
| 2 | os.pullEvent = os.pullEventRaw | |
| 3 | - | pass = "password" |
| 3 | + | term.clear() |
| 4 | term.setCursorPos( 1, 1 ) | |
| 5 | - | textutils.slowPrint("Derp Password Door thingy v0.1")
|
| 5 | + | |
| 6 | -- Variables | |
| 7 | pass = "GHS" | |
| 8 | - | sleep(1) |
| 8 | + | sideOut = "back" --side to power redstone when success |
| 9 | - | term.write("Password: ")
|
| 9 | + | lockSide = "right" --side of override lock switch |
| 10 | openTime = 6 | |
| 11 | -- End Variables | |
| 12 | - | if read("*") == pass then
|
| 12 | + | |
| 13 | local function loadAPI() | |
| 14 | - | term.write("Working")
|
| 14 | + | -- Check for H4X API |
| 15 | - | sleep(0.5) |
| 15 | + | write( "Checking for H4X API... " ) |
| 16 | - | term.write(". ")
|
| 16 | + | if not fs.exists( "H4X" ) then |
| 17 | print "Not found." | |
| 18 | print "Attempting to retrieve.." | |
| 19 | - | textutils.slowPrint("Access Granted!")
|
| 19 | + | -- GET API from pastebin |
| 20 | write( "Connecting to pastebin.com... " ) | |
| 21 | local APICode = "A5BRRZyZ" | |
| 22 | local response = http.get( | |
| 23 | - | print "Doh!" |
| 23 | + | "http://pastebin.com/raw.php?i="..textutils.urlEncode( APICode ) |
| 24 | ) | |
| 25 | - | end |
| 25 | + | if response then |
| 26 | print "Connected." | |
| 27 | local sResponse = response.readAll() | |
| 28 | response.close() | |
| 29 | write( "Writing file.." ) | |
| 30 | local sPath = "H4X" | |
| 31 | local file = fs.open( sPath, "w" ) | |
| 32 | file.write( sResponse ) | |
| 33 | print "done" | |
| 34 | file.close() | |
| 35 | print "Successfully got required API!" | |
| 36 | else | |
| 37 | print "Failed to fetch required API!" | |
| 38 | sleep( 2 ) | |
| 39 | print "Please make sure you are connected to the internet and then reboot this computer!" | |
| 40 | sleep( 2 ) | |
| 41 | print "Exiting..." | |
| 42 | shell.exit() | |
| 43 | end | |
| 44 | else | |
| 45 | print "API Found!" | |
| 46 | end | |
| 47 | write( "Loading H4X API... ") | |
| 48 | os.loadAPI( "H4X" ) | |
| 49 | print "Done!" | |
| 50 | sleep( 2 ) | |
| 51 | end | |
| 52 | ||
| 53 | local function checkOverride( side ) | |
| 54 | ||
| 55 | if redstone.getInput( side ) == true then | |
| 56 | term.setTextColor( colors.red ) | |
| 57 | textutils.slowPrint( "Override Lock is active! " ) | |
| 58 | sleep(2) | |
| 59 | os.shutdown() | |
| 60 | end | |
| 61 | ||
| 62 | end | |
| 63 | ||
| 64 | --loadAPI() | |
| 65 | ||
| 66 | -- Start main loop | |
| 67 | while true do | |
| 68 | ||
| 69 | term.setTextColor( colors.blue ) | |
| 70 | textutils.slowPrint( "H4X Security Door v1.0" ) | |
| 71 | print " " | |
| 72 | sleep( 1 ) | |
| 73 | ||
| 74 | checkOverride( lockSide ) | |
| 75 | ||
| 76 | term.setTextColor( colors.yellow ) | |
| 77 | write( "Password: " ) | |
| 78 | input = read( "*" ) | |
| 79 | if input == pass then | |
| 80 | ||
| 81 | checkOverride( lockSide ) | |
| 82 | ||
| 83 | print " " | |
| 84 | term.setTextColor( colors.orange ) | |
| 85 | write( "Working" ) | |
| 86 | --sleep( 0.5 ) | |
| 87 | write( ". " ) | |
| 88 | --sleep( 0.5 ) | |
| 89 | write( ". " ) | |
| 90 | --sleep(0.5) | |
| 91 | write( ". " ) | |
| 92 | --sleep( 0.5 ) | |
| 93 | write( ". " ) | |
| 94 | --sleep( 0.5 ) | |
| 95 | write( ". " ) | |
| 96 | sleep( 0.5 ) | |
| 97 | term.clear() | |
| 98 | term.setCursorPos( 1, 1 ) | |
| 99 | term.setTextColor( colors.green ) | |
| 100 | textutils.slowPrint( "Access Granted!" ) | |
| 101 | sleep( 1 ) | |
| 102 | print " " | |
| 103 | term.setTextColor( colors.white ) | |
| 104 | print( "Opening Security Door for " .. openTime .. " seconds..." ) | |
| 105 | rs.setOutput( sideOut, true ) | |
| 106 | sleep( openTime ) | |
| 107 | print " " | |
| 108 | print( "Security Door closing!" ) | |
| 109 | rs.setOutput( sideOut, false ) | |
| 110 | sleep( 1.5 ) | |
| 111 | term.clear() | |
| 112 | term.setCursorPos( 1, 1 ) | |
| 113 | term.setTextColor( colors.green ) | |
| 114 | textutils.slowPrint( ":D" ) | |
| 115 | sleep( 1.5 ) | |
| 116 | ||
| 117 | else | |
| 118 | ||
| 119 | checkOverride( lockSide ) | |
| 120 | ||
| 121 | print " " | |
| 122 | term.setTextColor( colors.orange ) | |
| 123 | write( "Working" ) | |
| 124 | --sleep( 0.5 ) | |
| 125 | write( ". " ) | |
| 126 | --sleep( 0.5 ) | |
| 127 | write( ". " ) | |
| 128 | --sleep(0.5) | |
| 129 | write( ". " ) | |
| 130 | --sleep( 0.5 ) | |
| 131 | write( ". " ) | |
| 132 | --sleep( 0.5 ) | |
| 133 | write( ". " ) | |
| 134 | sleep( 0.5 ) | |
| 135 | term.clear() | |
| 136 | term.setCursorPos( 1, 1 ) | |
| 137 | term.setTextColor( colors.red ) | |
| 138 | textutils.slowPrint( "Access Denied!" ) | |
| 139 | sleep( 3 ) | |
| 140 | term.clear() | |
| 141 | term.setCursorPos( 1, 1 ) | |
| 142 | textutils.slowPrint( "D:" ) | |
| 143 | sleep( 1.5 ) | |
| 144 | ||
| 145 | end | |
| 146 | end -- End main loop | |
| 147 | ||
| 148 | ||
| 149 | term.setTextColor( colors.red ) | |
| 150 | textutils.slowPrint( "Loop has been exited!" ) | |
| 151 | sleep( 2 ) | |
| 152 | term.setTextColor( colors.yellow ) | |
| 153 | print "" | |
| 154 | textutils.slowPrint( "Shutting down..." ) | |
| 155 | sleep( 1 ) | |
| 156 | os.shutdown() |