MCPcopy Create free account
hub / github.com/DFHack/dfhack / stockflow_cmd

Function stockflow_cmd

plugins/stockflow.cpp:299–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299static command_result stockflow_cmd(color_ostream &out, vector <string> & parameters) {
300 bool desired = enabled;
301 if (parameters.size() == 1) {
302 if (parameters[0] == "enable" || parameters[0] == "on" || parameters[0] == "1") {
303 desired = true;
304 fast = false;
305 } else if (parameters[0] == "disable" || parameters[0] == "off" || parameters[0] == "0") {
306 desired = false;
307 fast = false;
308 } else if (parameters[0] == "fast" || parameters[0] == "always" || parameters[0] == "2") {
309 desired = true;
310 fast = true;
311 } else if (parameters[0] == "usage" || parameters[0] == "help" || parameters[0] == "?") {
312 return CR_WRONG_USAGE;
313 } else if (parameters[0] == "list") {
314 if (!enabled) {
315 out.printerr("Stockflow is not currently enabled.\n");
316 return CR_FAILURE;
317 }
318
319 if (!Maps::IsValid()) {
320 out.printerr("You haven't loaded a map yet.\n");
321 return CR_FAILURE;
322 }
323
324 // Tell Lua to list any saved stockpile orders.
325 return helper.command_method("list_orders", out)? CR_OK: CR_FAILURE;
326 } else if (parameters[0] != "status") {
327 return CR_WRONG_USAGE;
328 }
329 } else if (parameters.size() > 1) {
330 return CR_WRONG_USAGE;
331 }
332
333 if (desired != enabled) {
334 if (!apply_hooks(out, desired)) {
335 return CR_FAILURE;
336 }
337 }
338
339 out.print("Stockflow is {} {}{}.\n", (desired == enabled)? "currently": "now", desired? "enabled": "disabled", fast? ", in fast mode": "");
340 enabled = desired;
341 return CR_OK;
342}
343
344
345DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) {

Callers

nothing calls this directly

Calls 4

apply_hooksFunction · 0.85
command_methodMethod · 0.80
sizeMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected