Advertisement
fatboychummy

emptier.lua

Aug 15th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. local side = "right"
  2.  
  3. local function on()
  4.   rs.setOutput(side, true)
  5. end
  6.  
  7. local function off()
  8.   rs.setOutput(side, false)
  9. end
  10.  
  11. local function check()
  12.   local s = peripheral.call(side, "size")
  13.   local items = peripheral.call(side, "list")
  14.   io.write(".")
  15.   for i = 1, s do
  16.     io.write(".")
  17.     if items[i] then
  18.       io.write(".")
  19.       return true
  20.     end
  21.   end
  22.   io.write(".")
  23.   return false
  24. end
  25.  
  26. local function switch()
  27.   while check() do
  28.     on()
  29.     os.sleep(0.2)
  30.     off()
  31.     os.sleep(0.2)
  32.   end
  33. end
  34.  
  35. while true do
  36.   print()
  37.   io.write("Running check")
  38.   if check() then
  39.     print()
  40.     print("Check passed (items in inventory), emptying.")
  41.     switch()
  42.     print()
  43.     print("Done.")
  44.   else
  45.     print("Check failed (no items in inventory), idling.")
  46.   end
  47.   os.sleep(5)
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement