SHARE
TWEET

furnace.lua

dreais Sep 15th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- VARIABLES
  2. modem = peripheral.wrap("back")
  3. furnaces = {}
  4. max_capacity = 0
  5. current_capacity = 0
  6.  
  7. -- FETCH ALL FURNACE GENERATORS AND CAPACITY
  8. for key, value in pairs(modem.getNamesRemote()) do
  9.     table.insert(furnaces, value)
  10. end
  11. max_capacity = table.getn(furnaces) * 64
  12.  
  13. -- MAIN FUNCTION / FETCHING CAPACITY AT ALL TIME
  14.  
  15. function main()
  16.     for key, value in pairs(furnaces) do
  17.         if modem.callRemote(value, "getStackInSlot", 1) then
  18.             current_capacity = current_capacity + modem.callRemote(tostring(value), "getStackInSlot", 1)["qty"]
  19.         end
  20.     end
  21.     print((current_capacity / max_capacity) * 100)
  22.     current_capacity = 0
  23.     os.sleep(1)
  24.     main()
  25. end
  26.  
  27. -- BREAKING FUNCTION
  28. function loop()
  29.     while true do
  30.         local _,key = os.pullEvent("key")
  31.         if key == keys.q then
  32.             break
  33.         end
  34.     end
  35. end
  36.  
  37. parallel.waitForAny(main, loop)
  38. print("PROGRAM ENDED")
  39. -- .callRemote(string peripheral, string method, va_arg)
  40.  
  41. -- .callRemote("generatorfurnace_N", "getStackInSlot", 1)["qty"]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top