@@ -87,6 +87,21 @@ local function persist_state()
8787 print_details ((" end persist_state" ))
8888end
8989
90+ local function read_persistent_config (key , index )
91+ return dfhack .internal .readPersistentSiteConfigInt (key , index )
92+ end
93+
94+ local function migrate_enabled_status_from_ccp_nestboxes ()
95+ print_local (" About to attempt migration from cpp to lua" )
96+ local nestboxes_status = read_persistent_config (" nestboxes/config" , " 0" )
97+ print_local ((" Migrating status %s from cpp nestboxes to lua" ):format (string_or_int_to_boolean [nestboxes_status ] and " enabled" or " disabled" ))
98+ state .enabled = string_or_int_to_boolean [nestboxes_status ] or false
99+ state .migration_from_cpp_to_lua_done = true
100+ dfhack .persistent [' deleteSiteData' ](" nestboxes/config" )
101+ persist_state ()
102+ print_local (" Migrating from cpp to lua done" )
103+ end
104+
90105--- Load the saved state of the script
91106local function load_state ()
92107 print_details ((" start load_state" ))
@@ -107,18 +122,7 @@ local function load_state()
107122 utils .assign (state , processed_persisted_data )
108123
109124 if not state .migration_from_cpp_to_lua_done then
110- print_local (" About to attempt migration from cpp to lua" )
111- local nestboxes_status = dfhack .run_command_silent (" nestboxes migrate_enabled_status" )
112- if nestboxes_status ~= nil and string_or_int_to_boolean [nestboxes_status ] then
113- print_local ((" Migrating status %s from cpp nestboxes to lua" ):format (string_or_int_to_boolean [nestboxes_status ] and " enabled" or " disabled" ))
114- state .enabled = string_or_int_to_boolean [nestboxes_status ]
115- state .migration_from_cpp_to_lua_done = true
116- dfhack .persistent [' deleteSiteData' ](" nestboxes/config" )
117- persist_state ()
118- else
119- print_local (" Did not get valid response from cpp nestboxes" )
120- end
121- print_local (" Migrating from cpp to lua done" )
125+ migrate_enabled_status_from_ccp_nestboxes ()
122126 end
123127
124128 print_details ((" end load_state" ))
0 commit comments