|
|
@ -73,6 +73,31 @@ function showHelp()
|
|
|
|
Disclaimer(helptext)
|
|
|
|
Disclaimer(helptext)
|
|
|
|
dialog.showMessage("Help!?!",helptext)
|
|
|
|
dialog.showMessage("Help!?!",helptext)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[ Util functions ]]--
|
|
|
|
|
|
|
|
function advGlobalPos()
|
|
|
|
|
|
|
|
local map=df.global.world.map
|
|
|
|
|
|
|
|
local wd=df.global.world.world_data
|
|
|
|
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
|
|
|
|
--wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y
|
|
|
|
|
|
|
|
--return wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y
|
|
|
|
|
|
|
|
--return wd.adv_region_x*16+wd.adv_emb_x+adv.pos.x/16,wd.adv_region_y*16+wd.adv_emb_y+adv.pos.y/16
|
|
|
|
|
|
|
|
--print(map.region_x,map.region_y,adv.pos.x,adv.pos.y)
|
|
|
|
|
|
|
|
--print(map.region_x+adv.pos.x/48, map.region_y+adv.pos.y/48,wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y)
|
|
|
|
|
|
|
|
return math.floor(map.region_x+adv.pos.x/48), math.floor(map.region_y+adv.pos.y/48)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function inSite()
|
|
|
|
|
|
|
|
local tx,ty=advGlobalPos()
|
|
|
|
|
|
|
|
--print(tx,ty)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for k,v in pairs(df.global.world.world_data.sites) do
|
|
|
|
|
|
|
|
local tp={v.pos.x,v.pos.y}
|
|
|
|
|
|
|
|
if tx>=tp[1]*16+v.rgn_min_x and tx<=tp[1]*16+v.rgn_max_x and
|
|
|
|
|
|
|
|
ty>=tp[2]*16+v.rgn_min_y and ty<=tp[2]*16+v.rgn_max_y then
|
|
|
|
|
|
|
|
--print(k)
|
|
|
|
|
|
|
|
return v
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
--[[ low level job management ]]--
|
|
|
|
--[[ low level job management ]]--
|
|
|
|
function getLastJobLink()
|
|
|
|
function getLastJobLink()
|
|
|
|
local st=df.global.world.job_list
|
|
|
|
local st=df.global.world.job_list
|
|
|
@ -827,6 +852,15 @@ function usetool:init(args)
|
|
|
|
visible=false,
|
|
|
|
visible=false,
|
|
|
|
text={
|
|
|
|
text={
|
|
|
|
{id="text1",gap=1,key=keybinds.workshop.key,key_sep="()", text="Workshop menu",pen=dfhack.pen.parse{fg=COLOR_YELLOW,bg=0}}}
|
|
|
|
{id="text1",gap=1,key=keybinds.workshop.key,key_sep="()", text="Workshop menu",pen=dfhack.pen.parse{fg=COLOR_YELLOW,bg=0}}}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wid.Label{
|
|
|
|
|
|
|
|
view_id="siteLabel",
|
|
|
|
|
|
|
|
frame = {t=1,xalign=-1,yalign=0},
|
|
|
|
|
|
|
|
visible=false,
|
|
|
|
|
|
|
|
text={
|
|
|
|
|
|
|
|
{id="text1", text="Site:"},{id="site", text="name"}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -948,7 +982,7 @@ function usetool:openPutWindow(building)
|
|
|
|
|
|
|
|
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
local items=EnumItems{pos=adv.pos,unit=adv,
|
|
|
|
local items=EnumItems{pos=adv.pos,unit=adv,
|
|
|
|
inv={[df.unit_inventory_item.T_mode.Hauled]=true,[df.unit_inventory_item.T_mode.Worn]=true,
|
|
|
|
inv={[df.unit_inventory_item.T_mode.Hauled]=true,--[df.unit_inventory_item.T_mode.Worn]=true,
|
|
|
|
[df.unit_inventory_item.T_mode.Weapon]=true,},deep=true}
|
|
|
|
[df.unit_inventory_item.T_mode.Weapon]=true,},deep=true}
|
|
|
|
local choices={}
|
|
|
|
local choices={}
|
|
|
|
for k,v in pairs(items) do
|
|
|
|
for k,v in pairs(items) do
|
|
|
@ -1040,7 +1074,12 @@ function usetool:armCleanTrap(building)
|
|
|
|
LoadStoneTrap,
|
|
|
|
LoadStoneTrap,
|
|
|
|
LoadWeaponTrap,
|
|
|
|
LoadWeaponTrap,
|
|
|
|
]]
|
|
|
|
]]
|
|
|
|
|
|
|
|
if building.trap_type==df.trap_type.Lever then
|
|
|
|
|
|
|
|
--link
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--building.trap_type==df.trap_type.PressurePlate then
|
|
|
|
|
|
|
|
--settings/link
|
|
|
|
local args={unit=adv,post_actions={AssignBuildingRef,AssignJobItems},pos=adv.pos,from_pos=adv.pos,job_type=df.job_type.CleanTrap}
|
|
|
|
local args={unit=adv,post_actions={AssignBuildingRef,AssignJobItems},pos=adv.pos,from_pos=adv.pos,job_type=df.job_type.CleanTrap}
|
|
|
|
if building.trap_type==df.trap_type.CageTrap then
|
|
|
|
if building.trap_type==df.trap_type.CageTrap then
|
|
|
|
args.job_type=df.job_type.LoadCageTrap
|
|
|
|
args.job_type=df.job_type.LoadCageTrap
|
|
|
@ -1157,7 +1196,7 @@ MODES={
|
|
|
|
input=usetool.operatePump,
|
|
|
|
input=usetool.operatePump,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[df.building_type.Trap]={
|
|
|
|
[df.building_type.Trap]={
|
|
|
|
name="Arm/Clean Trap",
|
|
|
|
name="Interact",
|
|
|
|
input=usetool.armCleanTrap,
|
|
|
|
input=usetool.armCleanTrap,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[df.building_type.Hive]={
|
|
|
|
[df.building_type.Hive]={
|
|
|
@ -1178,20 +1217,7 @@ function usetool:shopInput(keys)
|
|
|
|
self:openShopWindowButtoned(self.in_shop)
|
|
|
|
self:openShopWindowButtoned(self.in_shop)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function advGlobalPos()
|
|
|
|
|
|
|
|
local wd=df.global.world.world_data
|
|
|
|
|
|
|
|
return wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function inSite()
|
|
|
|
|
|
|
|
local tx,ty=advGlobalPos()
|
|
|
|
|
|
|
|
for k,v in pairs(df.global.world.world_data.sites) do
|
|
|
|
|
|
|
|
local tp={v.pos.x,v.pos.y}
|
|
|
|
|
|
|
|
if tx>=tp[1]*16+v.rgn_min_x and tx<=tp[1]*16+v.rgn_max_x and
|
|
|
|
|
|
|
|
ty>=tp[2]*16+v.rgn_min_y and ty<=tp[2]*16+v.rgn_max_y then
|
|
|
|
|
|
|
|
return v
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function usetool:setupFields()
|
|
|
|
function usetool:setupFields()
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
local civ_id=df.global.world.units.active[0].civ_id
|
|
|
|
local civ_id=df.global.world.units.active[0].civ_id
|
|
|
@ -1271,6 +1297,7 @@ function usetool:fieldInput(keys)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function usetool:onInput(keys)
|
|
|
|
function usetool:onInput(keys)
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
|
|
|
|
|
|
|
|
if keys.LEAVESCREEN then
|
|
|
|
if keys.LEAVESCREEN then
|
|
|
|
if df.global.cursor.x~=-30000 then
|
|
|
|
if df.global.cursor.x~=-30000 then
|
|
|
|
self:sendInputToParent("LEAVESCREEN")
|
|
|
|
self:sendInputToParent("LEAVESCREEN")
|
|
|
@ -1298,6 +1325,14 @@ function usetool:onInput(keys)
|
|
|
|
self:fieldInput(keys)
|
|
|
|
self:fieldInput(keys)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local site=inSite()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if site then
|
|
|
|
|
|
|
|
self.subviews.siteLabel.visible=true
|
|
|
|
|
|
|
|
self.subviews.siteLabel:itemById("site").text=dfhack.TranslateName(site.name)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
self.subviews.siteLabel.visible=false
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function usetool:isOnBuilding()
|
|
|
|
function usetool:isOnBuilding()
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|
local adv=df.global.world.units.active[0]
|
|
|
|