Advertisement
vantrop

computer_coal

Sep 15th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. local sides = { "top", "bottom", "left", "right", "front", "back" }
  2.  
  3. local peripheralType = "minecraft:ironchest_gold"
  4.  
  5. local mainPeripheral
  6.  
  7.  
  8.  
  9.  
  10. local function countCoal ()
  11.     local res = 0
  12.     local content = mainPeripheral.list()
  13.     for n=1,96 do
  14.         if content[n] ~= nil then
  15.             res = res + content[n]["count"]
  16.         end
  17.     end
  18.     coke = res
  19.     return res
  20. end
  21.  
  22.  
  23.  
  24. print("Finding " .. peripheralType .. "...")
  25. local found = false
  26. for i = 1, #sides do
  27.   if peripheral.isPresent(sides[i]) then
  28.         if peripheral.getType(sides[i]) == peripheralType then
  29.           print("Found: "..sides[i])
  30.           mainPeripheral = peripheral.wrap(sides[i])
  31.           found = true
  32.         end
  33.   end
  34. end
  35. local count
  36. if found then
  37.     redstone.setOutput("bottom",true)
  38.     while true do
  39.         count = countCoal()
  40.        
  41.  
  42.          -- TODO send output to rednet
  43.         sleep(900)
  44.     end
  45.  
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement