Advertisement
vantrop

computer_coke

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