From 767430efcae49cde3cca2489c2e64804cb101e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryszard=20Panto=C5=82?= Date: Wed, 11 Sep 2024 18:10:47 +0200 Subject: [PATCH] rename script to nestboxes --- eggwatch.lua => nestboxes.lua | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) rename eggwatch.lua => nestboxes.lua (98%) diff --git a/eggwatch.lua b/nestboxes.lua similarity index 98% rename from eggwatch.lua rename to nestboxes.lua index 2abb4dbf6..86aac7c94 100644 --- a/eggwatch.lua +++ b/nestboxes.lua @@ -4,7 +4,7 @@ local argparse = require("argparse") local eventful = require("plugins.eventful") local utils = require("utils") -local GLOBAL_KEY = "eggwatch" +local GLOBAL_KEY = "nestboxes" local default_table = {10, false, false} local string_or_int_to_boolean = {["true"] = true, ["false"] = false, ["1"] = true, ["0"] = false, ["Y"] = true, ["N"] = false, [1] = true, [0] = false} @@ -91,7 +91,7 @@ local function read_persistent_config(key, index) return dfhack.internal.readPersistentSiteConfigInt(key, index) end -local function migrate_enabled_status_from_ccp_nestboxes() +local function migrate_enabled_status_from_cpp_nestboxes() print_local("About to attempt migration from cpp to lua") local nestboxes_status = read_persistent_config("nestboxes/config", "0") 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() utils.assign(state, processed_persisted_data) if not state.migration_from_cpp_to_lua_done then - migrate_enabled_status_from_ccp_nestboxes() + migrate_enabled_status_from_cpp_nestboxes() end print_details(("end load_state")) @@ -168,10 +168,6 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc) update_event_listener() end -if dfhack_flags.module then - return -end - local function is_egg(item) return df.item_type.EGG == item:getType() end @@ -501,6 +497,9 @@ end load_state() local args, opts = {...}, {} +if dfhack_flags and dfhack_flags.enable then + args = {dfhack_flags.enable_state and "enable" or "disable"} +end local positionals = argparse.processArgsGetopt( args, @@ -515,18 +514,18 @@ local positionals = } ) -if dfhack_flags.enable then - if dfhack_flags.enable_state then - do_enable() - else - do_disable() - end +if dfhack_flags.module then + return end local command = positionals[1] if command == "help" or opts.help then print(dfhack.script_help()) +elseif command == "enable" then + do_enable() +elseif command == "disable" then + do_disable() elseif command == "target" then set_target(positionals[2], positionals[3], positionals[4], positionals[5]) print_status()