diff --git a/src/bin/TurtleCtl.hx b/src/bin/TurtleCtl.hx index 706be0d..cf612e9 100644 --- a/src/bin/TurtleCtl.hx +++ b/src/bin/TurtleCtl.hx @@ -48,6 +48,53 @@ class TurtleCtl extends CLIAppBase { handle.writeLine('${lvl}/${limit} (${(lvl / limit) * 100}%)'); return true; }); + + registerAsyncSubcommand("fuel-sources", (args) -> { + return asynPerform(() -> { + var items = InvManager.getCombustableItems(); + + for (i in items) { + handle.writeLine(i); + } + + return Success(null); + }, 1); + }); + + registerAsyncSubcommand("refuel", (args) -> { + var refuelTo = Turtle.getFuelLimit(); + if (args.length > 0) { + var split = args[0].split("%"); + + if (split.length > 1) { + // Is percentage + var parsed = Std.parseFloat(split[0]); + + if (parsed == null) { + handle.writeLine("Failed to parse ammount"); + return Future.sync(false); + } + + refuelTo = Math.round(refuelTo * (parsed / 100)); + } else { + // Is absolute + var parsed = Std.parseInt(args[0]); + + if (parsed == null) { + handle.writeLine("Failed to parse ammount"); + return Future.sync(false); + } + + refuelTo = parsed; + } + } + + return asynPerform(() -> { + InvManager.refuel(refuelTo, []); + + return Success(null); + }, 1); + }, ""); } private function asynPerform(op:Void->Outcome, times:Int):Future {