SHOW:
|
|
- or go back to the newest paste.
| 1 | os.loadAPI("ocs/apis/sensor")
| |
| 2 | - | inventorySensor = sensor.wrap("top")
|
| 2 | + | inventorySensor = sensor.wrap("right")
|
| 3 | ||
| 4 | - | fullTabletsKey = "0,-1,-2" |
| 4 | + | local fullTablets = 0 |
| 5 | - | emptyTabletsKey = "0,-1,-4" |
| 5 | + | local emptyTablets = 0 |
| 6 | ||
| 7 | local fullTabletKeys = {"0,-1,4","2,-1,4","4,-1,4","6,-1,4"}
| |
| 8 | local emptyTabletKeys = {"0,-1,0","2,-1,0","4,-1,0","6,-1,0"}
| |
| 9 | ||
| 10 | function countContent(inventoryKey) | |
| 11 | - | local content = 0 |
| 11 | + | |
| 12 | - | content = sensorReading["ItemCount"] |
| 12 | + | |
| 13 | --print(textutils.serialize(sensorReading)) | |
| 14 | local content = sensorReading["ItemCount"] | |
| 15 | return content | |
| 16 | - | while true do |
| 16 | + | |
| 17 | - | print("full tablets: " ..countContent(fullTabletsKey))
|
| 17 | + | |
| 18 | - | print("empty tablets: " ..countContent(emptyTabletsKey))
|
| 18 | + | function tabletCount() |
| 19 | - | sleep(30) |
| 19 | + | while true do |
| 20 | - | end |
| 20 | + | fullTablets = 0 |
| 21 | for key,val in ipairs(fullTabletKeys) do | |
| 22 | fullTablets = fullTablets + countContent(val) | |
| 23 | end | |
| 24 | emptyTablets = 0 | |
| 25 | for key,val in ipairs(emptyTabletKeys) do | |
| 26 | emptyTablets = emptyTablets + countContent(val) | |
| 27 | end | |
| 28 | sleep(10) | |
| 29 | end | |
| 30 | end | |
| 31 | ||
| 32 | function printTabletCount() | |
| 33 | while true do | |
| 34 | shell.run("clear")
| |
| 35 | print("full tablets: " ..fullTablets)
| |
| 36 | print("empty tablets: " ..emptyTablets)
| |
| 37 | print("tablets total: "..(fullTablets+emptyTablets) )
| |
| 38 | sleep(10) | |
| 39 | end | |
| 40 | end | |
| 41 | ||
| 42 | function craftTablets() | |
| 43 | while true do | |
| 44 | if ((fullTablets+emptyTablets)<5000) then | |
| 45 | redstone.setOutput("left",true)
| |
| 46 | sleep(1) | |
| 47 | redstone.setOutput("left",false)
| |
| 48 | sleep(1) | |
| 49 | end | |
| 50 | sleep(10) | |
| 51 | end | |
| 52 | end | |
| 53 | ||
| 54 | parallel.waitForAll(tabletCount,printTabletCount,craftTablets) |