|
|
|
@ -31,6 +31,7 @@ DFHACK_PLUGIN_IS_ENABLED(enabled);
|
|
|
|
|
bool enabled = false;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
bool fast = false;
|
|
|
|
|
const char *tagline = "Allows the fortress bookkeeper to queue jobs through the manager.";
|
|
|
|
|
const char *usage = (
|
|
|
|
|
" stockflow enable\n"
|
|
|
|
@ -59,6 +60,13 @@ class LuaHelper {
|
|
|
|
|
public:
|
|
|
|
|
void cycle(color_ostream &out) {
|
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
|
|
if (fast) {
|
|
|
|
|
// Ignore the bookkeeper; either gather or enqueue orders every cycle.
|
|
|
|
|
found = !bookkeeping;
|
|
|
|
|
} else {
|
|
|
|
|
// Gather orders when the bookkeeper starts updating stockpile records,
|
|
|
|
|
// and enqueue them when the job is done.
|
|
|
|
|
for (df::job_list_link* link = &df::global::world->job_list; link != NULL; link = link->next) {
|
|
|
|
|
if (link->item == NULL) continue;
|
|
|
|
|
if (link->item->job_type == job_type::UpdateStockpileRecords) {
|
|
|
|
@ -66,6 +74,7 @@ public:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found && !bookkeeping) {
|
|
|
|
|
command_method("start_bookkeeping", out);
|
|
|
|
@ -307,8 +316,13 @@ static command_result stockflow_cmd(color_ostream &out, vector <string> & parame
|
|
|
|
|
if (parameters.size() == 1) {
|
|
|
|
|
if (parameters[0] == "enable" || parameters[0] == "on" || parameters[0] == "1") {
|
|
|
|
|
desired = true;
|
|
|
|
|
fast = false;
|
|
|
|
|
} else if (parameters[0] == "disable" || parameters[0] == "off" || parameters[0] == "0") {
|
|
|
|
|
desired = false;
|
|
|
|
|
fast = false;
|
|
|
|
|
} else if (parameters[0] == "fast" || parameters[0] == "always" || parameters[0] == "2") {
|
|
|
|
|
desired = true;
|
|
|
|
|
fast = true;
|
|
|
|
|
} else if (parameters[0] == "usage" || parameters[0] == "help" || parameters[0] == "?") {
|
|
|
|
|
out.print("%s: %s\nUsage:\n%s", name, tagline, usage);
|
|
|
|
|
return CR_OK;
|
|
|
|
|