local dlg=require("gui.dialogs")
--this script is an experiment on testing the training mechanic in the game, so far works with caged non citizens of the fort. there also moments where the trainer will have issues and forget to bring food to the cage
-- if this happens then you kinda have to convert the caged unit to something trainable using dfhack then go through the vanilla process of selecting a trainer
-- you could also just delete the training assignment with in df.global.plotinfo.equipment with gm-editor and the alt-d input but that one of the more riskier bits of this
-- oh and folks that petition to join the fort don't need to constant training, but those that fully revert might need to be shove back in the cage so get some really good cage trap setups.
-- or caging scripts
function trainerselect()
local Ark={}
local civcheck=df.global.plotinfo.civ_id
for k,v in pairs(df.global.world.units.active) do
BoaName=dfhack.TranslateName(v.name)
if v.civ_id==civcheck and v.flags1.inactive==false then
table.insert (Ark,{dfhack.TranslateName(v.name).." "..v.name.nickname ..df.global.world.raws.creatures.all[v.race].creature_id..""..df.global.world.raws.creatures.all[v.race].name[0],nil,v.id})
end
end
table.insert (Ark,{"ANY",nil,"ANY"})
local f=function(Name,C)
cagedselect(C[3])
end
dlg.showListPrompt("trainer list","Select a unit for trainer role",COLOR_WHITE,Ark,f)
end
function cagedselect(e)
local Ark2={}
local civcheck=df.global.plotinfo.civ_id
for k,v in pairs(df.global.world.units.active) do
BoaName=dfhack.TranslateName(v.name)
if v.civ_id~=civcheck and v.flags1.caged and v.flags1.inactive==false then
table.insert (Ark2,{dfhack.TranslateName(v.name).." "..v.name.nickname ..df.global.world.raws.creatures.all[v.race].creature_id..""..df.global.world.raws.creatures.all[v.race].name[0],nil,v.id})
end
end
local f2=function(Name,C)
shove(C[3],e)
end
dlg.showListPrompt("caged list","Select a caged unit for training",COLOR_WHITE,Ark2,f2)
end
function shove(af,aw)
local train=df.global.plotinfo.equipment.training_assignments
if aw=="ANY" then
train:insert("#",{new=true,animal_id=af,trainer_id=-1})
train[#train-1].flags.any_trainer=true
else
train:insert("#",{new=true,animal_id=af,trainer_id=aw})
end
end
trainerselect()
local dlg=require("gui.dialogs")
--script that selects all wild creatures from the active unit lists and shove them in the currently selected cage
-- warning this doesn't have a filter on visible units and will select ALL wild units on the site
-- so you might have to scrub pass some cavern critters if you don't want your citizens wrestling beings way too large and deadly
function deitysummoning()
local Ark={}
for k,v in pairs(df.global.world.units.active) do
BoaName=dfhack.TranslateName(v.name)
if v.flags1.inactive==false and v.flags1.caged==false and v.civ_id~=df.global.plotinfo.civ_id and v.civ_id==-1 then
for ko,vo in pairs(df.global.world.buildings.other.IN_PLAY) do
if vo.id==df.global.game.main_interface.view_sheets.viewing_bldid then
vo.assigned_units:insert("#",v.id)
end
end
end
end
end
deitysummoning()
well here's two scripts I been working on well one I been working on a bunch the other is just to make use of it when it works.
the train caged script can work at least anywhere, but the cage wild requires you to look at the 'building cage' before running it.
wrote this stuff when I notice the game was training one of my sapient citizens when I didn't have any indicator saying they were going to be trained or still be trained but they had one before transforming into a sapient creature.
do hope one day I could figure out how to get into the training menu prompt but until then this is an "alternative to just toggling the tame unit flag, or force petitioning the unit" script
edit: due to some structure changes train cage script needs a few adjustments
local dlg=require("gui.dialogs")
--this script is an experiment on testing the training mechanic in the game, so far works with caged non citizens of the fort. there also moments where the trainer will have issues and forget to bring food to the cage
-- if this happens then you kinda have to convert the caged unit to something trainable using dfhack then go through the vanilla process of selecting a trainer
-- you could also just delete the training assignment with in df.global.plotinfo.equipment with gm-editor and the alt-d input but that one of the more riskier bits of this
-- oh and folks that petition to join the fort don't need to constant training, but those that fully revert might need to be shove back in the cage so get some really good cage trap setups.
-- or caging scripts
function trainerselect()
local Ark={}
local civcheck=df.global.plotinfo.civ_id
for k,v in pairs(df.global.world.units.active) do
BoaName=dfhack.TranslateName(v.name)
if v.civ_id==civcheck and v.flags1.inactive==false then
table.insert (Ark,{dfhack.TranslateName(v.name).." "..v.name.nickname ..df.global.world.raws.creatures.all[v.race].creature_id..""..df.global.world.raws.creatures.all[v.race].name[0],nil,v.id})
end
end
table.insert (Ark,{"ANY",nil,"ANY"})
local f=function(Name,C)
cagedselect(C[3])
end
dlg.showListPrompt("trainer list","Select a unit for trainer role",COLOR_WHITE,Ark,f)
end
function cagedselect(e)
local Ark2={}
local civcheck=df.global.plotinfo.civ_id
for k,v in pairs(df.global.world.units.active) do
BoaName=dfhack.TranslateName(v.name)
if v.civ_id~=civcheck and v.flags1.caged and v.flags1.inactive==false then
table.insert (Ark2,{dfhack.TranslateName(v.name).." "..v.name.nickname ..df.global.world.raws.creatures.all[v.race].creature_id..""..df.global.world.raws.creatures.all[v.race].name[0],nil,v.id})
end
end
local f2=function(Name,C)
shove(C[3],e)
end
dlg.showListPrompt("caged list","Select a caged unit for training",COLOR_WHITE,Ark2,f2)
end
function shove(af,aw)
local train=df.global.plotinfo.training.training_assignments
if aw=="ANY" then
train:insert("#",{new=true,animal_id=af,trainer_id=-1})
train[#train-1].flags.any_trainer=true
else
train:insert("#",{new=true,animal_id=af,trainer_id=aw})
end
end
trainerselect()
still working on fixing a weird quirk that stops the workers from fetching food to the trainee in the cage.