Advertisement
systox

pamacha tür 2

Sep 26th, 2020
1,056
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. cable_side = "back"
  2. input_side = "front"
  3.  
  4. function load_state()
  5.     file = fs.open("state", "r")
  6.     state = file.readAll()
  7.    
  8.     return state
  9. end
  10.  
  11. function save_state(state)
  12.     file = fs.open("state", "w")
  13.     file.write(state)
  14.     file.close()
  15. end
  16.  
  17. function open_door()
  18.     rs.setBundledOutput(cable_side, colors.lime)
  19.     sleep(.5)
  20.    
  21.     rs.setBundledOutput(cable_side, 0)
  22.     sleep(.5)
  23.    
  24.     rs.setBundledOutput(cable_side, colors.combine(colors.lime, colors.gray))
  25.     sleep(.5)
  26.    
  27.     rs.setBundledOutput(cable_side, 0)
  28.     sleep(.5)
  29.    
  30.     rs.setBundledOutput(cable_side, colors.combine(colors.lime, colors.gray, colors.brown))
  31.     sleep(.5)
  32.    
  33.     rs.setBundledOutput(cable_side, 0)
  34.     sleep(.5)
  35.    
  36.     rs.setBundledOutput(cable_side, colors.combine(colors.lime, colors.gray, colors.brown, colors.black))
  37.     sleep(.5)
  38. end
  39.  
  40. function close_door()
  41.     rs.setBundledOutput(cable_side, colors.combine(colors.white, colors.orange, colors.yellow, colors.lightBlue))
  42.     sleep(.5)
  43.    
  44.     rs.setBundledOutput(cable_side, 0)
  45.     sleep(.5)
  46.    
  47.     rs.setBundledOutput(cable_side, colors.combine(colors.orange, colors.yellow, colors.lightBlue))
  48.     sleep(.5)
  49.    
  50.     rs.setBundledOutput(cable_side, 0)
  51.     sleep(.5)
  52.    
  53.     rs.setBundledOutput(cable_side, colors.combine(colors.yellow, colors.lightBlue))
  54.     sleep(.5)
  55.    
  56.     rs.setBundledOutput(cable_side, 0)
  57.     sleep(.5)
  58.    
  59.     rs.setBundledOutput(cable_side, colors.lightBlue)
  60.     sleep(.5)
  61. end
  62.  
  63. while true do
  64.     os.pullEvent("redstone")
  65.    
  66.     if rs.getInput(input_side) then
  67.         if load_state() == "true" then --tür auf
  68.             close_door()
  69.             save_state("false")
  70.            
  71.         elseif load_state() == "false" then --tür zu
  72.             open_door()
  73.             save_state("true")
  74.            
  75.         end
  76.     end
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement