Advertisement
sniki10

Drzwi na plytke

Aug 8th, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. bundleSide = "bottom" --White to door, Orange to "negative" noteblock, Magenta to "accept" noteblock
  2. password = "please open the door"
  3. debug_char = "0" -- leave nil to disable
  4.  
  5. term.clear()
  6.  
  7. function mainLoop()
  8. while(true) do
  9. event, driveSide = os.pullEventRaw()
  10. if(event=="disk" and driveSide) then
  11. path = disk.getMountPath(driveSide)
  12. if(path) then
  13. path = path.."/access" --reading from "access" file
  14. file = (fs.exists(path)) and io.open(path, "r") or nil
  15. end
  16. disk.eject(driveSide)
  17. if(file and file:read()==password) then
  18. for t=1,5,1 do
  19. rs.setBundledOutput(bundleSide, colors.white+colors.magenta)
  20. sleep(0.5)
  21. rs.setBundledOutput(bundleSide, colors.white)
  22. sleep(0.5)
  23. end
  24. rs.setBundledOutput(bundleSide, colors.orange)
  25. sleep(0.5)
  26. rs.setBundledOutput(bundleSide, 0)
  27. else
  28. rs.setBundledOutput(bundleSide, colors.orange)
  29. sleep(0.5)
  30. rs.setBundledOutput(bundleSide, 0)
  31. end
  32. if(file) then file:close() file = nil end
  33. elseif(debug_char and event=="char" and driveSide==debug_char) then return("break") end
  34. end
  35. end
  36.  
  37. rs.setBundledOutput(bundleSide, 0)
  38. sfile = io.open("/startup", "w")
  39. sfile:write('shell.run("acr")')
  40. sfile:close()
  41.  
  42. repeat
  43. ok, err, val = pcall(mainLoop)
  44. if(not ok and err) then
  45. if(err=="Terminated") then print("Access denied.")
  46. else print(err) end
  47. rs.setBundledOutput(bundleSide, 0)
  48. end
  49. until(ok and err=="break")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement