SHOW:
|
|
- or go back to the newest paste.
| 1 | os.loadAPI("ocs/apis/sensor")
| |
| 2 | os.loadAPI("ocs/apis/graph")
| |
| 3 | - | local usedamount = 0 |
| 3 | + | |
| 4 | local i = 0 | |
| 5 | local targets = prox.getTargets() | |
| 6 | - | local usage = 0 |
| 6 | + | |
| 7 | - | --print(textutils.serialize(prox.getTargets())) |
| 7 | + | |
| 8 | print("Found Tank: "..name)
| |
| 9 | tankDetails = prox.getTargetDetails(name) | |
| 10 | if (tankDetails ~= nil) then | |
| 11 | tank = name | |
| 12 | break | |
| 13 | end | |
| 14 | end | |
| 15 | - | print("That Works")
|
| 15 | + | |
| 16 | if type == "item.fuel" then | |
| 17 | type = "Fuel" | |
| 18 | end | |
| 19 | ||
| 20 | function update() | |
| 21 | - | local init = tankDetails.Tanks[1].Amount |
| 21 | + | |
| 22 | - | local capacity = tankDetails.Tanks[1].Capacity |
| 22 | + | |
| 23 | - | local type = tankDetails.Tanks[1].Name |
| 23 | + | |
| 24 | amount = amt.Tanks[1].Amount | |
| 25 | capacity = amt.Tanks[1].Capacity | |
| 26 | if amount < (capacity / 2) then | |
| 27 | redstone.setOutput("right",false)
| |
| 28 | end | |
| 29 | - | function comma_value(amount) |
| 29 | + | return amount |
| 30 | - | local formatted = amount |
| 30 | + | |
| 31 | - | while true do |
| 31 | + | |
| 32 | - | formatted, k = string.gsub(formatted,"^(-?%d+) (%d%d%d)", '%1,%2') |
| 32 | + | |
| 33 | - | if (k==0) then |
| 33 | + | |
| 34 | - | break |
| 34 | + | |
| 35 | - | end |
| 35 | + | |
| 36 | - | end |
| 36 | + | |
| 37 | - | return formatted |
| 37 | + | |
| 38 | end | |
| 39 | ||
| 40 | - | function round(val, decimal) |
| 40 | + | |
| 41 | - | if (decimal) then |
| 41 | + | |
| 42 | - | return math.floor( (val * 10^decimal) + 0.5 / (10^decimal) ) |
| 42 | + | |
| 43 | - | else |
| 43 | + | |
| 44 | - | return math.floor(val+0.5) |
| 44 | + | |
| 45 | graphInstance:draw() | |
| 46 | newLine() | |
| 47 | mon.write(" Consuming: ")
| |
| 48 | - | function format_num(amount, decimal,prefix, neg_prefix) |
| 48 | + | |
| 49 | - | local str_amount, formatted, famount, remain |
| 49 | + | |
| 50 | - | |
| 50 | + | |
| 51 | - | decimal = decimal or 2 |
| 51 | + | |
| 52 | - | neg_prefix = neg_prefix or "-" |
| 52 | + | |
| 53 | - | |
| 53 | + | |
| 54 | - | famount = math.abs(round(amount,decimal)) |
| 54 | + | |
| 55 | - | famount = math.floor(famount) |
| 55 | + | |
| 56 | - | |
| 56 | + | |
| 57 | - | remain = round(math.abs(amount) - famount, decimal) |
| 57 | + | |
| 58 | - | |
| 58 | + | |
| 59 | - | formatted = comma_value(famount) |
| 59 | + |