MCPcopy Create free account
hub / github.com/DFHack/dfhack / command_result plugin_enable

Function command_result plugin_enable

plugins/autobutcher.cpp:83–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
84 if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
85 out.printerr("Cannot enable {} without a loaded fort.\n", plugin_name);
86 return CR_FAILURE;
87 }
88
89 if (enable != is_enabled) {
90 is_enabled = enable;
91 DEBUG(control,out).print("{} from the API; persisting\n",
92 is_enabled ? "enabled" : "disabled");
93 config.set_bool(CONFIG_IS_ENABLED, is_enabled);
94 // don't autorun cycle on first frame of fortress so we don't mark animals for butchering before
95 // all initial configuration has been applied
96 if (enable && plotinfo->fortress_age > 0)
97 autobutcher_cycle(out);
98 } else {
99 DEBUG(control,out).print("{} from the API, but already {}; no action\n",
100 is_enabled ? "enabled" : "disabled",
101 is_enabled ? "enabled" : "disabled");
102 }
103 return CR_OK;
104}
105
106DFhackCExport command_result plugin_shutdown (color_ostream &out) {
107 DEBUG(control,out).print("shutting down {}\n", plugin_name);

Callers

nothing calls this directly

Calls 2

autobutcher_cycleFunction · 0.85
printMethod · 0.45

Tested by

no test coverage detected