refine docs, logging, help text

develop
myk002 2022-08-03 16:18:22 -07:00 committed by Myk
parent 06f1f533ac
commit f400ee50f8
3 changed files with 38 additions and 29 deletions

@ -35,7 +35,7 @@ other commands).
Plugins can also register handlers to run on every tick, and can interface with Plugins can also register handlers to run on every tick, and can interface with
the built-in `enable` and `disable` commands. For the full plugin API, see the the built-in `enable` and `disable` commands. For the full plugin API, see the
example plugins or ``PluginManager.cpp``. example ``skeleton`` plugin or ``PluginManager.cpp``.
Installed plugins live in the ``hack/plugins`` folder of a DFHack installation, Installed plugins live in the ``hack/plugins`` folder of a DFHack installation,
and the `load` family of commands can be used to load a recompiled plugin and the `load` family of commands can be used to load a recompiled plugin

@ -119,7 +119,7 @@ DFhackCExport command_result plugin_load_data (color_ostream &out) {
} }
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) { DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) {
if (event == DFHack::SC_MAP_UNLOADED) { if (event == DFHack::SC_WORLD_UNLOADED) {
if (is_enabled) { if (is_enabled) {
DEBUG(status,out).print("world unloaded; disabling %s\n", DEBUG(status,out).print("world unloaded; disabling %s\n",
plugin_name); plugin_name);

@ -98,31 +98,37 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
// Invoked with DF suspended, and always before the matching plugin_onupdate. // Invoked with DF suspended, and always before the matching plugin_onupdate.
// More event codes may be added in the future. // More event codes may be added in the future.
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) { DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) {
DEBUG(status,out).print("game state changed: %d\n", event); switch (event) {
case SC_UNKNOWN:
if (is_enabled) { DEBUG(status,out).print("game state changed: SC_UNKNOWN\n");
switch (event) { break;
case SC_UNKNOWN: case SC_WORLD_LOADED:
break; DEBUG(status,out).print("game state changed: SC_WORLD_LOADED\n");
case SC_WORLD_LOADED: break;
break; case SC_WORLD_UNLOADED:
case SC_WORLD_UNLOADED: DEBUG(status,out).print("game state changed: SC_WORLD_UNLOADED\n");
break; break;
case SC_MAP_LOADED: case SC_MAP_LOADED:
break; DEBUG(status,out).print("game state changed: SC_MAP_LOADED\n");
case SC_MAP_UNLOADED: break;
break; case SC_MAP_UNLOADED:
case SC_VIEWSCREEN_CHANGED: DEBUG(status,out).print("game state changed: SC_MAP_UNLOADED\n");
break; break;
case SC_CORE_INITIALIZED: case SC_VIEWSCREEN_CHANGED:
break; DEBUG(status,out).print("game state changed: SC_VIEWSCREEN_CHANGED\n");
case SC_BEGIN_UNLOAD: break;
break; case SC_CORE_INITIALIZED:
case SC_PAUSED: DEBUG(status,out).print("game state changed: SC_CORE_INITIALIZED\n");
break; break;
case SC_UNPAUSED: case SC_BEGIN_UNLOAD:
break; DEBUG(status,out).print("game state changed: SC_BEGIN_UNLOAD\n");
} break;
case SC_PAUSED:
DEBUG(status,out).print("game state changed: SC_PAUSED\n");
break;
case SC_UNPAUSED:
DEBUG(status,out).print("game state changed: SC_UNPAUSED\n");
break;
} }
return CR_OK; return CR_OK;
@ -145,14 +151,17 @@ DFhackCExport command_result plugin_onupdate (color_ostream &out) {
DFhackCExport command_result plugin_save_data (color_ostream &out) { DFhackCExport command_result plugin_save_data (color_ostream &out) {
DEBUG(status,out).print("save or unload is imminent; time to persist state\n"); DEBUG(status,out).print("save or unload is imminent; time to persist state\n");
// Call functions in the Persistence module here. // Call functions in the Persistence module here. If your PersistantDataItem
// objects are already up to date, then they will get persisted with the
// save automatically and there is nothing extra you need to do here.
return CR_OK; return CR_OK;
} }
DFhackCExport command_result plugin_load_data (color_ostream &out) { DFhackCExport command_result plugin_load_data (color_ostream &out) {
DEBUG(status,out).print("world is loading; time to load persisted state\n"); DEBUG(status,out).print("world is loading; time to load persisted state\n");
// Call functions in the Persistence module here. // Call functions in the Persistence module here. See
// persistent_per_save_example.cpp for an example.
return CR_OK; return CR_OK;
} }