@@ -4,7 +4,7 @@ local argparse = require("argparse")
4
4
local eventful = require (" plugins.eventful" )
5
5
local utils = require (" utils" )
6
6
7
- local GLOBAL_KEY = " eggwatch "
7
+ local GLOBAL_KEY = " nestboxes "
8
8
local default_table = {10 , false , false }
9
9
local string_or_int_to_boolean = {[" true" ] = true , [" false" ] = false , [" 1" ] = true , [" 0" ] = false , [" Y" ] = true , [" N" ] = false , [1 ] = true , [0 ] = false }
10
10
@@ -91,7 +91,7 @@ local function read_persistent_config(key, index)
91
91
return dfhack .internal .readPersistentSiteConfigInt (key , index )
92
92
end
93
93
94
- local function migrate_enabled_status_from_ccp_nestboxes ()
94
+ local function migrate_enabled_status_from_cpp_nestboxes ()
95
95
print_local (" About to attempt migration from cpp to lua" )
96
96
local nestboxes_status = read_persistent_config (" nestboxes/config" , " 0" )
97
97
print_local ((" Migrating status %s from cpp nestboxes to lua" ):format (string_or_int_to_boolean [nestboxes_status ] and " enabled" or " disabled" ))
@@ -122,7 +122,7 @@ local function load_state()
122
122
utils .assign (state , processed_persisted_data )
123
123
124
124
if not state .migration_from_cpp_to_lua_done then
125
- migrate_enabled_status_from_ccp_nestboxes ()
125
+ migrate_enabled_status_from_cpp_nestboxes ()
126
126
end
127
127
128
128
print_details ((" end load_state" ))
@@ -168,10 +168,6 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc)
168
168
update_event_listener ()
169
169
end
170
170
171
- if dfhack_flags .module then
172
- return
173
- end
174
-
175
171
local function is_egg (item )
176
172
return df .item_type .EGG == item :getType ()
177
173
end
501
497
502
498
load_state ()
503
499
local args , opts = {... }, {}
500
+ if dfhack_flags and dfhack_flags .enable then
501
+ args = {dfhack_flags .enable_state and " enable" or " disable" }
502
+ end
504
503
local positionals =
505
504
argparse .processArgsGetopt (
506
505
args ,
@@ -515,18 +514,18 @@ local positionals =
515
514
}
516
515
)
517
516
518
- if dfhack_flags .enable then
519
- if dfhack_flags .enable_state then
520
- do_enable ()
521
- else
522
- do_disable ()
523
- end
517
+ if dfhack_flags .module then
518
+ return
524
519
end
525
520
526
521
local command = positionals [1 ]
527
522
528
523
if command == " help" or opts .help then
529
524
print (dfhack .script_help ())
525
+ elseif command == " enable" then
526
+ do_enable ()
527
+ elseif command == " disable" then
528
+ do_disable ()
530
529
elseif command == " target" then
531
530
set_target (positionals [2 ], positionals [3 ], positionals [4 ], positionals [5 ])
532
531
print_status ()
0 commit comments