Advertisement
jschuldes

rtest

Apr 5th, 2020
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- MC Eternal mod pack
  2. -- operates the garage door - open at sunrise, close at sunset
  3.  
  4. -- pastebin -f get R9uZxYxJ rtest
  5.  
  6. local robot=require("robot")
  7. local computer=require("computer")
  8. local component=require("component")
  9. local sides = require("sides")
  10.  
  11. -- functions
  12.  
  13. -- main
  14.  
  15. local doorstate = "closed"
  16. local daycheck = 1.0
  17.  
  18. while true do
  19.   -- is it sunrise?
  20.   if doorstate == "closed" then
  21.      daycheck = component.redstone.getInput(sides.back)
  22.      daycheck = math.floor(daycheck)
  23.      print(daycheck)
  24.  
  25.     if daycheck >= 2 then
  26.       -- sunrise open the door
  27.       robot.use()
  28.       robot.use()
  29.       -- set a flag to note that the door is open
  30.       doorstate = "open"
  31.     end
  32.   end
  33.  
  34.   -- is it sunset?
  35.   if doorstate == "open" then
  36.     daycheck = component.redstone.getInput(sides.back)
  37.     daycheck = math.floor(daycheck)
  38.     print(daycheck)
  39.  
  40.     if daycheck <= 0 then
  41.       -- sunset close the door
  42.       robot.use()
  43.       robot.use()
  44.       -- set a flag to note that the door is closed
  45.       doorstate = "closed"
  46.     end
  47.   end
  48.  
  49.   -- wait
  50.   os.sleep(20)
  51. end
  52. -- eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement