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

Function command_result plugin_enable

plugins/autochop.cpp:124–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
125 if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
126 out.printerr("Cannot enable {} without a loaded fort.\n", plugin_name);
127 return CR_FAILURE;
128 }
129
130 if (enable != is_enabled) {
131 is_enabled = enable;
132 DEBUG(control,out).print("{} from the API; persisting\n",
133 is_enabled ? "enabled" : "disabled");
134 config.set_bool(CONFIG_IS_ENABLED, is_enabled);
135 if (enable)
136 do_cycle(out, true);
137 } else {
138 DEBUG(control,out).print("{} from the API, but already {}; no action\n",
139 is_enabled ? "enabled" : "disabled",
140 is_enabled ? "enabled" : "disabled");
141 }
142 return CR_OK;
143}
144
145DFhackCExport command_result plugin_shutdown (color_ostream &out) {
146 DEBUG(control,out).print("shutting down {}\n", plugin_name);

Callers

nothing calls this directly

Calls 2

do_cycleFunction · 0.70
printMethod · 0.45

Tested by

no test coverage detected