Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- inventorySensor = sensor.wrap("right")
- local fullTablets = 0
- local emptyTablets = 0
- local fullTabletKeys = {"0,-1,4","2,-1,4","4,-1,4","6,-1,4"}
- local emptyTabletKeys = {"0,-1,0","2,-1,0","4,-1,0","6,-1,0"}
- function countContent(inventoryKey)
- local sensorReading = {}
- sensorReading = inventorySensor.getTargetDetails(inventoryKey)
- --print(textutils.serialize(sensorReading))
- local content = sensorReading["ItemCount"]
- return content
- end
- function tabletCount()
- while true do
- fullTablets = 0
- for key,val in ipairs(fullTabletKeys) do
- fullTablets = fullTablets + countContent(val)
- end
- emptyTablets = 0
- for key,val in ipairs(emptyTabletKeys) do
- emptyTablets = emptyTablets + countContent(val)
- end
- sleep(10)
- end
- end
- function printTabletCount()
- while true do
- shell.run("clear")
- print("full tablets: " ..fullTablets)
- print("empty tablets: " ..emptyTablets)
- print("tablets total: "..(fullTablets+emptyTablets) )
- sleep(10)
- end
- end
- function craftTablets()
- while true do
- if ((fullTablets+emptyTablets)<5000) then
- redstone.setOutput("left",true)
- sleep(1)
- redstone.setOutput("left",false)
- sleep(1)
- end
- sleep(10)
- end
- end
- parallel.waitForAll(tabletCount,printTabletCount,craftTablets)
Advertisement
Add Comment
Please, Sign In to add comment