SHOW:
|
|
- or go back to the newest paste.
| 1 | --------------- | |
| 2 | -- BY UPZONE -- | |
| 3 | --------------- | |
| 4 | ||
| 5 | os.loadAPI("builder\\apis\\Colors")
| |
| 6 | ||
| 7 | - | UNLIMITED_FUEL = -1 |
| 7 | + | function getItemCount(slots) |
| 8 | count = 0 | |
| 9 | - | function getFuelLevel() |
| 9 | + | for i, v in pairs(slots) do |
| 10 | - | level = turtle.getFuelLevel() |
| 10 | + | count = count + turtle.getItemCount(v) |
| 11 | - | if level == "unlimited" then |
| 11 | + | |
| 12 | - | return UNLIMITED_FUEL |
| 12 | + | return count |
| 13 | end | |
| 14 | - | return level |
| 14 | + | |
| 15 | function itemCountStatus(count, slots) | |
| 16 | currentCount = getItemCount(slots) | |
| 17 | if currentCount > count then | |
| 18 | - | function getFuelLimit() |
| 18 | + | currentCount = count |
| 19 | - | limit = turtle.getFuelLimit() |
| 19 | + | |
| 20 | - | if limit == "unlimited" then |
| 20 | + | countStringLength = string.len(tostring(count)) |
| 21 | - | return UNLIMITED_FUEL |
| 21 | + | text = string.format("[%0" .. countStringLength.. "d/" .. count .. "]", currentCount)
|
| 22 | ||
| 23 | - | return limit |
| 23 | + | if currentCount >= count then |
| 24 | -- enough items | |
| 25 | term.blit(text, string.rep(Colors.lime, string.len(text)), string.rep(Colors.black, string.len(text))) | |
| 26 | return true | |
| 27 | - | function requestFuel(to, startX, startY) |
| 27 | + | |
| 28 | - | -- already enough fuel |
| 28 | + | -- not enough |
| 29 | - | if getFuelLevel() > to then |
| 29 | + | |
| 30 | - | return |
| 30 | + | return false |
| 31 | end | |
| 32 | - | |
| 32 | + |