By request, a lua script with function to insert pets if they don't already exist
Note this won't add the creature to the wagon, pack, mount, minion, or exotic lists - just as a pet.
The code is rather unoptimized for CPU usage.
--comment
local function insertPet(alpha,beta,gamma)
local exists=false
for k,v in pairs(df.global.world.entities.all) do
--ENTITY TYPES
--Civilization 0
--SiteGovernment 1
--VesselCrew 2
--MigratingGroup 3
--NomadicGroup 4
--Religion 5
--MilitaryUnit 6
--Outcast 7
if v.type==0 and v.entity_raw.code==alpha then --exclude bandits
--print(k)
--printall(v.resources.animals)
for kk,vv in pairs(v.resources.animals.pet_races) do
--print(kk,vv,v.resources.animals.pet_castes[kk])
local checkrace = df.creature_raw.find(vv)
local checkcaste = checkrace.caste[v.resources.animals.pet_castes[kk]]
--print(checkrace.creature_id, checkcaste.caste_id)
if checkrace.creature_id == beta and checkcaste.caste_id == gamma then exists=true end
end
if exists==true then
print("ERROR- civilization ",alpha," has creature ", beta, gamma)
else
--the civ doesn't have the creature as a pet
--add the creature as a pet
local racenum=-1
local castenum=-1
for kk,vv in pairs(df.global.world.raws.creatures.all) do
--print(vv.creature_id)
if vv.creature_id==beta then
racenum=kk
--print(kk)
--printall(vv.caste)
for kkk,vvv in pairs(vv.caste) do
--print(vvv.caste_id)
if vvv.caste_id==gamma then castenum=kkk end
end
break
end
end
if racenum > -1 and castenum > -1 then
--print("success!!")
--print(v)
v.resources.animals.pet_races:insert('#',racenum)
v.resources.animals.pet_castes:insert('#',castenum)
print("Inserted ", beta, gamma, " in civ ",k, alpha)
else
print(beta, gamma, " not found in raws")
end
end
end
exists=false
end
end
--for example add CREATURE:DOG to ENTITY:PLAINS and CREATURE:HORSE to ENTITY:FOREST?
--As in: Humans have dogs and elves have horses
insertPet("PLAINS","DOG","MALE")
insertPet("PLAINS","DOG","FEMALE")
insertPet("FOREST","HORSE","MALE")
insertPet("FOREST","HORSE","FEMALE")
insertPet("MOUNTAIN","DRAGON","MALE")
insertPet("MOUNTAIN","DRAGON","FEMALE")