From 472a0c4a79f558fea3f17d665b4301d7b492627e Mon Sep 17 00:00:00 2001 From: Andriel Chaoti <3628387+AndrielChaoti@users.noreply.github.com> Date: Sun, 10 Sep 2023 00:21:31 -0600 Subject: [PATCH 1/4] update autofish to use argparse.boolean --- autofish.lua | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/autofish.lua b/autofish.lua index aa11d72fe4..d2e67e73e0 100644 --- a/autofish.lua +++ b/autofish.lua @@ -206,23 +206,16 @@ if dfhack_flags and dfhack_flags.enable then args = {dfhack_flags.enable_state and "enable" or "disable"} end --- lookup to convert arguments to bool values. -local toBool={["true"]=true,["yes"]=true,["y"]=true,["on"]=true,["1"]=true, - ["false"]=false,["no"]=false,["n"]=false,["off"]=false,["0"]=false} - +-- handle options flags local positionals = argparse.processArgsGetopt(args, {{"r", "raw", hasArg=true, handler=function(optArg) - optArg=string.lower(optArg) - if toBool[optArg] ~= nil then - set_useRaw(toBool[optArg]) - else - qerror("Invalid argument to --raw \"".. optArg .."\". expected boolean") - end + return argparse.boolean(optArg, "raw") end} }) load_state() +-- handle the rest of the arguments if positionals[1] == "enable" then enabled = true From d4660e198c3c4c6dbf792a2ce3502bc7b8b35bef Mon Sep 17 00:00:00 2001 From: Andriel Chaoti <3628387+AndrielChaoti@users.noreply.github.com> Date: Mon, 11 Sep 2023 22:47:23 -0600 Subject: [PATCH 2/4] fix a bug that caused raw flag to not be settable --- autofish.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autofish.lua b/autofish.lua index d2e67e73e0..b80c3d1b08 100644 --- a/autofish.lua +++ b/autofish.lua @@ -210,7 +210,8 @@ end local positionals = argparse.processArgsGetopt(args, {{"r", "raw", hasArg=true, handler=function(optArg) - return argparse.boolean(optArg, "raw") + local val = argparse.boolean(optArg, "raw") + set_useRaw(val) end} }) From 345d63761c28232a10fe37b18a12948b607b20ea Mon Sep 17 00:00:00 2001 From: Andriel Chaoti <3628387+AndrielChaoti@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:16:17 -0600 Subject: [PATCH 3/4] update to reflect changes in naming --- autofish.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autofish.lua b/autofish.lua index b80c3d1b08..dc7814a1e7 100644 --- a/autofish.lua +++ b/autofish.lua @@ -73,7 +73,7 @@ end function toggle_fishing_labour(state) -- pass true to state to turn on, otherwise disable -- find all work details that have fishing enabled: - local work_details = df.global.plotinfo.hauling.work_details + local work_details = df.global.plotinfo.labor_info.work_details for _,v in pairs(work_details) do if v.allowed_labors.FISH then -- set limited to true just in case a custom work detail is being From 47b0576c9be1f59f2cb6b4bef01c7c5b09bb22c9 Mon Sep 17 00:00:00 2001 From: Myk Date: Fri, 6 Oct 2023 23:06:11 -0700 Subject: [PATCH 4/4] Update autofish.lua --- autofish.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autofish.lua b/autofish.lua index dc7814a1e7..d5ce23d43c 100644 --- a/autofish.lua +++ b/autofish.lua @@ -73,7 +73,7 @@ end function toggle_fishing_labour(state) -- pass true to state to turn on, otherwise disable -- find all work details that have fishing enabled: - local work_details = df.global.plotinfo.labor_info.work_details + local work_details = df.global.plotinfo.hauling.labor_info.work_details for _,v in pairs(work_details) do if v.allowed_labors.FISH then -- set limited to true just in case a custom work detail is being