advfort.lua: added BuildLast for mass building of e.g. walls etc.

develop
Warmist 2013-03-06 00:22:59 +02:00
parent bb85d361eb
commit 5be2ecb080
1 changed files with 43 additions and 21 deletions

@ -43,7 +43,7 @@ for k,v in ipairs({...}) do --setting parsing
end end
mode=mode or 0 mode=mode or 0
last_building=last_building or {}
function Disclaimer(tlb) function Disclaimer(tlb)
local dsc={"The Gathering Against ",{text="Goblin ",pen=dfhack.pen.parse{fg=COLOR_GREEN,bg=0}}, "Oppresion ", local dsc={"The Gathering Against ",{text="Goblin ",pen=dfhack.pen.parse{fg=COLOR_GREEN,bg=0}}, "Oppresion ",
@ -368,7 +368,12 @@ function BuildingChosen(inp_args,type_id,subtype_id,custom_id)
if inp_args then if inp_args then
args.pos=inp_args.pos or args.pos args.pos=inp_args.pos or args.pos
end end
last_building.type=args.type
last_building.subtype=args.subtype
last_building.custom=args.custom
if chooseBuildingWidthHeightDir(args) then if chooseBuildingWidthHeightDir(args) then
return return
end end
--if settings.build_by_items then --if settings.build_by_items then
@ -736,10 +741,7 @@ function AssignJobItems(args)
return true return true
--]=] --]=]
end end
function AssignJobToBuild(args) function CheckAndFinishBuilding(args,bld)
local bld=dfhack.buildings.findAtTile(args.pos)
args.job_type=df.job_type.ConstructBuilding
if bld~=nil then
for idx,job in pairs(bld.jobs) do for idx,job in pairs(bld.jobs) do
if job.job_type==df.job_type.ConstructBuilding then if job.job_type==df.job_type.ConstructBuilding then
args.job=job args.job=job
@ -760,11 +762,30 @@ function AssignJobToBuild(args)
local ok,msg=makeJob(args) local ok,msg=makeJob(args)
return ok,msg return ok,msg
end end
end
function AssignJobToBuild(args)
local bld=dfhack.buildings.findAtTile(args.pos)
args.job_type=df.job_type.ConstructBuilding
if bld~=nil then
CheckAndFinishBuilding(args,bld)
else else
bdialog.BuildingDialog{on_select=dfhack.curry(BuildingChosen,args),hide_none=true}:show() bdialog.BuildingDialog{on_select=dfhack.curry(BuildingChosen,args),hide_none=true}:show()
end end
return true return true
end end
function BuildLast(args)
local bld=dfhack.buildings.findAtTile(args.pos)
args.job_type=df.job_type.ConstructBuilding
if bld~=nil then
CheckAndFinishBuilding(args,bld)
else
--bdialog.BuildingDialog{on_select=dfhack.curry(BuildingChosen,args),hide_none=true}:show()
if last_building and last_building.type then
BuildingChosen(args,last_building.type,last_building.subtype,last_building.custom)
end
end
return true
end
function CancelJob(unit) function CancelJob(unit)
local c_job=unit.job.current_job local c_job=unit.job.current_job
if c_job then if c_job then
@ -814,6 +835,7 @@ actions={
{"RemoveStairs" ,df.job_type.RemoveStairs,{IsStairs,NotConstruct}}, {"RemoveStairs" ,df.job_type.RemoveStairs,{IsStairs,NotConstruct}},
--{"HandleLargeCreature" ,df.job_type.HandleLargeCreature,{isUnit},{SetCreatureRef}}, --{"HandleLargeCreature" ,df.job_type.HandleLargeCreature,{isUnit},{SetCreatureRef}},
{"Build" ,AssignJobToBuild,{NoConstructedBuilding}}, {"Build" ,AssignJobToBuild,{NoConstructedBuilding}},
{"BuildLast" ,BuildLast,{NoConstructedBuilding}},
{"Clean" ,df.job_type.Clean,{}}, {"Clean" ,df.job_type.Clean,{}},
} }