Advertisement
sinkir

lua computer 3x3 door

Oct 5th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. -- pastebin get rU7eAYTj ftw
  2. -- -------------------------------------------
  3. -- 3x3 door -Sinkir-
  4. -- Version 1
  5. -- setup :
  6. -- Computer with 3 repater on 3 side
  7. -- 1 dust under the computer whith block and repeater
  8. -- 1 restone signal in front (input).
  9. -- 3 output rednet cable (3 colors)
  10. -- view from top
  11. -- r r r
  12. -- r R r
  13. -- rRCRr
  14. --   I
  15. -- r = rednet cable
  16. -- R = repeater
  17. -- C = Computer
  18. -- I = Input (redstone)
  19. -- -------------------------------------------
  20.  
  21.  
  22. function fileGet(path)
  23.         if(fs.exists(path))then
  24.                 tabFile = fs.open(path, "r")
  25.                 text = tabFile.readAll()
  26.                 tabFile.close()
  27.                 return text
  28.         else
  29.                 print("fileGet() File not found.")
  30.                 print(path)
  31.                 return false
  32.         end
  33. end
  34.  
  35. function fileSet(path, text)
  36.         if(fs.isReadOnly(path))then
  37.                 print("fileSet() File is read only.")
  38.                 print(path)
  39.                 return false
  40.         else
  41.                 tabFile = fs.open(path, "w")
  42.                 tabFile.write(text)
  43.                 tabFile.close()
  44.                 return true
  45.         end
  46. end
  47.  
  48. function savedata()
  49.     fileSet("data", a)
  50. end
  51.  
  52. function input(side)
  53.     redstone.setOutput(side, true)
  54.     sleep(0.1)
  55.     redstone.setOutput(side, false)
  56.    
  57. end
  58.  
  59.  
  60. if(fs.exists("data")==true)then
  61.     --Shaundi()
  62. else
  63.     fileSet("data", "0")
  64. end
  65.  
  66. a = fileGet("data")
  67.  
  68. flag = false
  69. while(2)do
  70.     if(redstone.getInput("front") == true and flag == false)then
  71.         --
  72.         if(a == "0")then
  73.             --opening
  74.             input("right")
  75.             sleep(0.1)
  76.             input("bottom")
  77.             sleep(0.1)
  78.             input("left")
  79.             sleep(0.1)
  80.             input("back")
  81.             sleep(0.1)
  82.             input("left")
  83.             sleep(0.1)
  84.             input("right")
  85.            
  86.             a = "1"
  87.         else
  88.             --closing
  89.             input("right")
  90.             input("back")  
  91.             input("bottom")
  92.             input("right")
  93.  
  94.            
  95.             a = "0"
  96.         end
  97.         savedata()
  98.  
  99.  
  100.         flag = true  
  101.     end
  102.     if(redstone.getInput("front") == false)then
  103.         flag = false
  104.     end
  105.     sleep(0.2)
  106. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement