|
|
@ -11,6 +11,9 @@ keybinding. (e.g. ``keybinding set Ctrl-T gui/advfort``). Possible arguments:
|
|
|
|
:-a, --nodfassign: uses different method to assign items.
|
|
|
|
:-a, --nodfassign: uses different method to assign items.
|
|
|
|
:-i, --inventory: checks inventory for possible items to use in the job.
|
|
|
|
:-i, --inventory: checks inventory for possible items to use in the job.
|
|
|
|
:-c, --cheat: relaxes item requirements for buildings (e.g. walls from bones). Implies -a
|
|
|
|
:-c, --cheat: relaxes item requirements for buildings (e.g. walls from bones). Implies -a
|
|
|
|
|
|
|
|
:-u, --unsafe: ignores dangerous conditions.
|
|
|
|
|
|
|
|
:-s, --safe: only allow building and etc. only if in site
|
|
|
|
|
|
|
|
:-q, --quick: quick item select mode
|
|
|
|
:job: selects that job (e.g. Dig or FellTree)
|
|
|
|
:job: selects that job (e.g. Dig or FellTree)
|
|
|
|
|
|
|
|
|
|
|
|
An example of player digging in adventure mode:
|
|
|
|
An example of player digging in adventure mode:
|
|
|
@ -22,8 +25,13 @@ An example of player digging in adventure mode:
|
|
|
|
=end]]
|
|
|
|
=end]]
|
|
|
|
|
|
|
|
|
|
|
|
--[==[
|
|
|
|
--[==[
|
|
|
|
version: 0.044
|
|
|
|
version: 0.05
|
|
|
|
changelog:
|
|
|
|
changelog:
|
|
|
|
|
|
|
|
*0.05
|
|
|
|
|
|
|
|
- fixed some reactions not showing. Now there is a '[fallback]' choice to choose from other way of getting reactions.
|
|
|
|
|
|
|
|
- fixed brewing accepting too many items instead of barrel
|
|
|
|
|
|
|
|
- fixed tallow making to accept fat
|
|
|
|
|
|
|
|
- display filters
|
|
|
|
*0.044
|
|
|
|
*0.044
|
|
|
|
- added output to clear_jobs of number of cleared jobs
|
|
|
|
- added output to clear_jobs of number of cleared jobs
|
|
|
|
- another failed attempt at gather plants fix
|
|
|
|
- another failed attempt at gather plants fix
|
|
|
@ -663,7 +671,7 @@ function RemoveBuilding(args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function isSuitableItem(job_item,item)
|
|
|
|
function isSuitableItem(job_item,item)
|
|
|
|
--todo butcher test
|
|
|
|
|
|
|
|
if job_item.item_type~=-1 then
|
|
|
|
if job_item.item_type~=-1 then
|
|
|
|
if item:getType()~= job_item.item_type then
|
|
|
|
if item:getType()~= job_item.item_type then
|
|
|
|
return false, "type"
|
|
|
|
return false, "type"
|
|
|
@ -696,29 +704,31 @@ function isSuitableItem(job_item,item)
|
|
|
|
return false,"already cooked"
|
|
|
|
return false,"already cooked"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if type(job_item) ~= "table" and not matinfo:matches(job_item) then
|
|
|
|
if job_item.has_material_reaction_product~="" then
|
|
|
|
--[[
|
|
|
|
local ok=false
|
|
|
|
local true_flags={}
|
|
|
|
for k,v in pairs(matinfo.material.reaction_product.id) do
|
|
|
|
for k,v in pairs(job_item.flags1) do
|
|
|
|
if v.value==job_item.has_material_reaction_product then
|
|
|
|
if v then
|
|
|
|
ok=true
|
|
|
|
table.insert(true_flags,k)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for k,v in pairs(job_item.flags2) do
|
|
|
|
if not ok then
|
|
|
|
if v then
|
|
|
|
return false, "no material reaction product"
|
|
|
|
table.insert(true_flags,k)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for k,v in pairs(job_item.flags3) do
|
|
|
|
if job_item.reaction_class~="" then
|
|
|
|
if v then
|
|
|
|
local ok=false
|
|
|
|
table.insert(true_flags,k)
|
|
|
|
for k,v in pairs(matinfo.material.reaction_class) do
|
|
|
|
|
|
|
|
if v.value==job_item.reaction_class then
|
|
|
|
|
|
|
|
ok=true
|
|
|
|
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for k,v in pairs(true_flags) do
|
|
|
|
if not ok then
|
|
|
|
print(v)
|
|
|
|
return false, "no material reaction class"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
--]]
|
|
|
|
end
|
|
|
|
|
|
|
|
if type(job_item) ~= "table" and not matinfo:matches(job_item) then
|
|
|
|
return false,"matinfo"
|
|
|
|
return false,"matinfo"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- some bonus checks:
|
|
|
|
-- some bonus checks:
|
|
|
@ -732,6 +742,7 @@ function isSuitableItem(job_item,item)
|
|
|
|
return false,"metal ore"
|
|
|
|
return false,"metal ore"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if job_item.min_dimension~=-1 then
|
|
|
|
if job_item.min_dimension~=-1 then
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- if #job_item.contains~=0 then
|
|
|
|
-- if #job_item.contains~=0 then
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
@ -740,30 +751,35 @@ function isSuitableItem(job_item,item)
|
|
|
|
return false,"tool use"
|
|
|
|
return false,"tool use"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if job_item.has_material_reaction_product~="" then
|
|
|
|
|
|
|
|
local ok=false
|
|
|
|
if job_item.flags3.food_storage and not item:isFoodStorage() then
|
|
|
|
for k,v in pairs(matinfo.material.reaction_product.id) do
|
|
|
|
return false,"not food storage"
|
|
|
|
if v.value==job_item.has_material_reaction_product then
|
|
|
|
|
|
|
|
ok=true
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if job_item.flags1.empty and dfhack.items.getGeneralRef(item,df.general_ref_type.CONTAINS_ITEM) then
|
|
|
|
|
|
|
|
return false,"not empty"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if not ok then
|
|
|
|
--[[
|
|
|
|
return false, "no material reaction product"
|
|
|
|
local true_flags={}
|
|
|
|
|
|
|
|
for k,v in pairs(job_item.flags1) do
|
|
|
|
|
|
|
|
if v then
|
|
|
|
|
|
|
|
table.insert(true_flags,k.." f1")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if job_item.reaction_class~="" then
|
|
|
|
for k,v in pairs(job_item.flags2) do
|
|
|
|
local ok=false
|
|
|
|
if v then
|
|
|
|
for k,v in pairs(matinfo.material.reaction_class) do
|
|
|
|
table.insert(true_flags,k.." f2")
|
|
|
|
if v.value==job_item.reaction_class then
|
|
|
|
|
|
|
|
ok=true
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if not ok then
|
|
|
|
for k,v in pairs(job_item.flags3) do
|
|
|
|
return false, "no material reaction class"
|
|
|
|
if v then
|
|
|
|
|
|
|
|
table.insert(true_flags,k.." f3")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for k,v in pairs(true_flags) do
|
|
|
|
|
|
|
|
print(v)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--]]
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function getItemsUncollected(job)
|
|
|
|
function getItemsUncollected(job)
|
|
|
@ -1386,7 +1402,37 @@ function usetool:onWorkShopButtonClicked(building,index,choice)
|
|
|
|
self:openShopWindowButtoned(building,true)
|
|
|
|
self:openShopWindowButtoned(building,true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function usetool:openShopWindowFallback( building,list)
|
|
|
|
|
|
|
|
local open_window=false
|
|
|
|
|
|
|
|
if not list then --if list is not passed we are responsible for showing the menu
|
|
|
|
|
|
|
|
list={}
|
|
|
|
|
|
|
|
open_window=true
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local filter_pile=workshopJobs.getJobs(building:getType(),building:getSubtype(),building:getCustomType())
|
|
|
|
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
|
|
|
|
local state={unit=adv,from_pos={x=adv.pos.x,y=adv.pos.y, z=adv.pos.z},building=building
|
|
|
|
|
|
|
|
,screen=self,bld=building}
|
|
|
|
|
|
|
|
if filter_pile then
|
|
|
|
|
|
|
|
local count=0
|
|
|
|
|
|
|
|
state.common=filter_pile.common
|
|
|
|
|
|
|
|
for i,v in ipairs(filter_pile) do
|
|
|
|
|
|
|
|
local label=v.name:lower()
|
|
|
|
|
|
|
|
table.insert(list,{job_id=0,text=label,filter=v})
|
|
|
|
|
|
|
|
count=count+1
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if open_window then
|
|
|
|
|
|
|
|
dialog.showListPrompt("Workshop job choice", "Choose what to make",
|
|
|
|
|
|
|
|
COLOR_WHITE,list,
|
|
|
|
|
|
|
|
function (index,choice)
|
|
|
|
|
|
|
|
onWorkShopJobChosen(state,index,choice)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
,nil, nil,true)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--no reset here means that the button opens submenu
|
|
|
|
function usetool:openShopWindowButtoned(building,no_reset)
|
|
|
|
function usetool:openShopWindowButtoned(building,no_reset)
|
|
|
|
self:setupFields()
|
|
|
|
self:setupFields()
|
|
|
|
local wui=df.global.ui_sidebar_menus.workshop_job
|
|
|
|
local wui=df.global.ui_sidebar_menus.workshop_job
|
|
|
@ -1396,45 +1442,47 @@ function usetool:openShopWindowButtoned(building,no_reset)
|
|
|
|
for k,v in pairs(wui.material_category) do
|
|
|
|
for k,v in pairs(wui.material_category) do
|
|
|
|
wui.material_category[k]=false
|
|
|
|
wui.material_category[k]=false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
--]]
|
|
|
|
|
|
|
|
--[[building:fillSidebarMenu()
|
|
|
|
|
|
|
|
if #wui.choices_all>0 then
|
|
|
|
|
|
|
|
wui.choices_all[#wui.choices_all-1]:click()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--]]
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
building:fillSidebarMenu()
|
|
|
|
building:fillSidebarMenu()
|
|
|
|
|
|
|
|
|
|
|
|
local list={}
|
|
|
|
local list={}
|
|
|
|
|
|
|
|
local names_already_in={}
|
|
|
|
for id,choice in pairs(wui.choices_visible) do
|
|
|
|
for id,choice in pairs(wui.choices_visible) do
|
|
|
|
table.insert(list,{text=utils.call_with_string(choice,"getLabel"),button=choice})
|
|
|
|
local label=string.lower(utils.call_with_string(choice,"getLabel"))
|
|
|
|
|
|
|
|
table.insert(list,{text=label,button=choice,is_button=true})
|
|
|
|
|
|
|
|
names_already_in[label]=true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if #list ==0 and not no_reset then
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
print("Fallback")
|
|
|
|
local state={unit=adv,from_pos={x=adv.pos.x,y=adv.pos.y, z=adv.pos.z},building=building
|
|
|
|
self:openShopWindow(building)
|
|
|
|
,screen=self,bld=building}
|
|
|
|
return
|
|
|
|
if #list==0 then
|
|
|
|
--qerror("No jobs for this workshop")
|
|
|
|
--we couldn't use the df hack so let's fill the list from fallback
|
|
|
|
|
|
|
|
self:openShopWindowFallback(building,list)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
--the hack worked. Though we are not sure how well so let's add a button for fallback
|
|
|
|
|
|
|
|
table.insert(list,{text='[fallback]'})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
dialog.showListPrompt("Workshop job choice", "Choose what to make",COLOR_WHITE,list,self:callback("onWorkShopButtonClicked",building)
|
|
|
|
|
|
|
|
,nil, nil,true)
|
|
|
|
if #list==0 then
|
|
|
|
|
|
|
|
qerror("no jobs for this shop")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function usetool:openShopWindow(building)
|
|
|
|
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local filter_pile=workshopJobs.getJobs(building:getType(),building:getSubtype(),building:getCustomType())
|
|
|
|
dialog.showListPrompt("Workshop job choice", "Choose what to make",
|
|
|
|
if filter_pile then
|
|
|
|
COLOR_WHITE,list,
|
|
|
|
local state={unit=adv,from_pos={x=adv.pos.x,y=adv.pos.y, z=adv.pos.z},building=building
|
|
|
|
function (index,choice)
|
|
|
|
,screen=self,bld=building,common=filter_pile.common}
|
|
|
|
if choice.text=="[fallback]" then
|
|
|
|
choices={}
|
|
|
|
self:openShopWindowFallback(building)
|
|
|
|
for k,v in pairs(filter_pile) do
|
|
|
|
return
|
|
|
|
table.insert(choices,{job_id=0,text=v.name:lower(),filter=v})
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
dialog.showListPrompt("Workshop job choice", "Choose what to make",COLOR_WHITE,choices,dfhack.curry(onWorkShopJobChosen,state)
|
|
|
|
if choice.is_button then
|
|
|
|
,nil, nil,true)
|
|
|
|
self:onWorkShopButtonClicked(building,index,choice)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
qerror("No jobs for this workshop")
|
|
|
|
onWorkShopJobChosen(state,index,choice)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
,nil, nil,true)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function track_stop_configure(bld) --TODO: dedicated widget with nice interface and current setting display
|
|
|
|
function track_stop_configure(bld) --TODO: dedicated widget with nice interface and current setting display
|
|
|
|
local dump_choices={
|
|
|
|
local dump_choices={
|
|
|
|
{text="no dumping"},
|
|
|
|
{text="no dumping"},
|
|
|
|