Jayex_Designs

potatoCounter

Jun 9th, 2021 (edited)
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. args = {...}
  2. if not args[1] then
  3.     error("Set the id of the server")
  4. end
  5. ServerId = tonumber(args[1])
  6. PreviousPotatoQuantity = 0
  7. PotatoQuantity = 0
  8. Chest = peripheral.find("minecraft:chest")
  9. rednet.open("right")
  10.  
  11. while true do
  12.     PotatoQuantity = 0
  13.     local items = Chest.list()
  14.     for slot, item in pairs(items) do
  15.         PotatoQuantity = PotatoQuantity + item.count
  16.     end
  17.     if (PreviousPotatoQuantity ~= PotatoQuantity) then
  18.         rednet.send(ServerId, PotatoQuantity, "potatoQuantity")
  19.     end
  20.     PreviousPotatoQuantity = PotatoQuantity
  21.     sleep(5)
  22. end
Advertisement
Add Comment
Please, Sign In to add comment