Skip to content

Commit fe2212d

Browse files
committed
output status when run without params
1 parent 3f61e23 commit fe2212d

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

plugins/autonestbox.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ static const string autonestbox_help =
4141
"Usage:\n"
4242
"\n"
4343
"enable autonestbox\n"
44-
" Start checking for unpastured egg-layers and assigning them to nestbox zones.\n"
44+
" Start checking for unpastured egg-layers and assigning them to nestbox zones.\n"
45+
"autonestbox\n"
46+
" Print current status."
4547
"autonestbox now\n"
46-
" Run a scan and assignment cycle right now. Does not require that the plugin is enabled.\n"
48+
" Run a scan and assignment cycle right now. Does not require that the plugin is enabled.\n"
4749
"autonestbox ticks <ticks>\n"
48-
" Change the number of ticks between scan and assignment cycles when the plugin is enabled.\n"
49-
" The default is 6000 (about 8 days)\n";
50+
" Change the number of ticks between scan and assignment cycles when the plugin is enabled.\n"
51+
" The default is 6000 (about 8 days)\n";
5052

5153
namespace DFHack {
5254
DBG_DECLARE(autonestbox, status);
@@ -56,8 +58,8 @@ namespace DFHack {
5658
static const string CONFIG_KEY = "autonestbox/config";
5759
static PersistentDataItem config;
5860
enum ConfigValues {
59-
IS_ENABLED = 0,
60-
CYCLE_TICKS = 1,
61+
CONFIG_IS_ENABLED = 0,
62+
CONFIG_CYCLE_TICKS = 1,
6163
};
6264
static int get_config_val(int index) {
6365
if (!config.isValid())
@@ -103,15 +105,15 @@ static void init_autonestbox(color_ostream &out) {
103105
if (!config.isValid())
104106
config = World::AddPersistentData(CONFIG_KEY);
105107

106-
if (get_config_val(IS_ENABLED) == -1) {
107-
set_config_val(IS_ENABLED, 0);
108-
set_config_val(CYCLE_TICKS, 6000);
108+
if (get_config_val(CONFIG_IS_ENABLED) == -1) {
109+
set_config_val(CONFIG_IS_ENABLED, 0);
110+
set_config_val(CONFIG_CYCLE_TICKS, 6000);
109111
}
110112

111113
if (is_enabled)
112-
set_config_val(IS_ENABLED, 1);
114+
set_config_val(CONFIG_IS_ENABLED, 1);
113115
else
114-
is_enabled = (get_config_val(IS_ENABLED) == 1);
116+
is_enabled = (get_config_val(CONFIG_IS_ENABLED) == 1);
115117
did_complain = false;
116118
}
117119

@@ -167,7 +169,8 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
167169
}
168170

169171
DFhackCExport command_result plugin_onupdate(color_ostream &out) {
170-
if (is_enabled && ++cycle_counter >= (size_t)get_config_val(CYCLE_TICKS))
172+
if (is_enabled && ++cycle_counter >=
173+
(size_t)get_config_val(CONFIG_CYCLE_TICKS))
171174
autonestbox_cycle(out);
172175
return CR_OK;
173176
}
@@ -209,12 +212,15 @@ static command_result df_autonestbox(color_ostream &out, vector<string> &paramet
209212
return CR_WRONG_USAGE;
210213

211214
if (opts.ticks > -1) {
212-
set_config_val(CYCLE_TICKS, opts.ticks);
215+
set_config_val(CONFIG_CYCLE_TICKS, opts.ticks);
213216
INFO(status,out).print("New cycle timer: %d ticks.\n", opts.ticks);
214217
}
215218
else if (opts.now) {
216219
autonestbox_cycle(out);
217220
}
221+
else {
222+
out << "autonestbox is " << (is_enabled ? "" : "not ") << "running\n";
223+
}
218224
return CR_OK;
219225
}
220226

0 commit comments

Comments
 (0)