tommy2805

sensore pioggia computercraft

Jan 3rd, 2022 (edited)
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.53 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. local mySensor = sensor.wrap("top")
  3. local target_list = {}
  4.  
  5. function getEvent()
  6.   target_list = mySensor.getTargetDetails("CURRENT")
  7.   return target_list["Raining"]
  8. end
  9.  
  10. function home()
  11.   while true do
  12.     if getEvent() then
  13.       rs.setOutput("right",true)
  14.       print("pioggia rilevata")
  15.       sleep(1)
  16.       rs.setOutput("right",false)
  17.       while getEvent() do
  18.         sleep(10)
  19.       end
  20.       term.clear()
  21.       term.setCursorPos(1,1)
  22.     end
  23.     sleep(1)  
  24.   end
  25. end
  26. home()
  27.  
Advertisement
Add Comment
Please, Sign In to add comment