systox

pamacha tür 1

Sep 26th, 2020 (edited)
767
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     for i=0,1 do
  19.         rs.setBundledOutput(cable_side, colors.black)
  20.         sleep(.5)
  21.         rs.setBundledOutput(cable_side, 0)
  22.         sleep(.5)
  23.     end
  24. end
  25.  
  26. function close_door()
  27.     for i=0,1 do
  28.         rs.setBundledOutput(cable_side, colors.white)
  29.         sleep(.5)
  30.         rs.setBundledOutput(cable_side, 0)
  31.         sleep(.5)
  32.     end
  33. end
  34.  
  35. while true do
  36.     os.pullEvent("redstone")
  37.    
  38.     if rs.getInput(input_side) then
  39.         if load_state() == "true" then --tür auf
  40.             close_door()
  41.             save_state("false")
  42.            
  43.         elseif load_state() == "false" then --tür zu
  44.             open_door()
  45.             save_state("true")
  46.            
  47.         end
  48.     end
  49. end
RAW Paste Data