Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc updates to autofish #855

Merged
merged 6 commits into from
Oct 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions autofish.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.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
Expand Down Expand Up @@ -206,23 +206,17 @@ 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
local val = argparse.boolean(optArg, "raw")
set_useRaw(val)
end}
})

load_state()
-- handle the rest of the arguments
if positionals[1] == "enable" then
enabled = true

Expand Down