Urist Da Vinci: I once tried adding poisonous giant mushrooms to the first cavern. You cant distinguish them from the other giant mushroom trees, but when felled they generated an evaporating log that had a slightly-harmful syndrome attached.
In short, cutting mushrooms in the caverns had a little danger attached to it.
The problem I encountered is that the wagon, any wooden embark item, and any wooden caravan item has a chance to consist of this wood. The caravan appears on the map, the wood evaporates, caravans is affected and turns around. Or you wagon deconstructs at embark, same for barrels holding your booze.
Question: Can your script remove this specific wood from a civs embark/trading, so that I can add poisonous mushrooms back into the caverns?
Yep. The following script will allow you to SEE what wood that the player's civ can bring:
local my_entity=df.historical_entity.find(df.global.ui.civ_id)
for k,v in pairs(my_entity.resources.organic.wood.mat_type) do
sText=dfhack.matinfo.decode(v,my_entity.resources.organic.wood.mat_index[k])
print(sText)
if (sText==nil) then
--print("nil")
else
--print("OK")
print(sText.plant.id)
end
end
FAKEEDIT: It's a bit more complicated.
Can't just purge the wood type - that only prevents them from bringing logs (and the embark wagon itself), training weapons, trap components, toys, instruments, and tools. Presumably also wood armor for elves.
Have to also seperately find and drop the wood from the crafts, barrels, buckets, splints, and crutches. Will take a few more minutes to code.
EDIT:
Remove the dreaded CEDAR trees from all spots that I could find in the resources of all civs in the world! Do a text replace if you want to target another tree type. Run the script before embark if you don't want a 2% chance of the embark wagon exploding in poison gas.local my_entity=df.historical_entity.find(df.global.ui.civ_id)
local sText=" "
local k=0
local v=1
for x,y in pairs(df.global.world.entities.all) do
my_entity=y
k=0
while k < #my_entity.resources.organic.wood.mat_index do
v=my_entity.resources.organic.wood.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.organic.wood.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.organic.wood.mat_type:erase(k)
my_entity.resources.organic.wood.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="CEDAR") then
my_entity.resources.organic.wood.mat_type:erase(k)
my_entity.resources.organic.wood.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end
k=0
while k < #my_entity.resources.misc_mat.crafts.mat_index do
v=my_entity.resources.misc_mat.crafts.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.crafts.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.misc_mat.crafts.mat_type:erase(k)
my_entity.resources.misc_mat.crafts.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="CEDAR") then
my_entity.resources.misc_mat.crafts.mat_type:erase(k)
my_entity.resources.misc_mat.crafts.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end
k=0
while k < #my_entity.resources.misc_mat.barrels.mat_index do
v=my_entity.resources.misc_mat.barrels.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.barrels.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.misc_mat.barrels.mat_type:erase(k)
my_entity.resources.misc_mat.barrels.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="CEDAR") then
my_entity.resources.misc_mat.barrels.mat_type:erase(k)
my_entity.resources.misc_mat.barrels.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end
k=0
while k < #my_entity.resources.misc_mat.wood2.mat_index do
v=my_entity.resources.misc_mat.wood2.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.wood2.mat_index[k])
if (sText==nil) then
--LIQUID wood2
my_entity.resources.misc_mat.wood2.mat_type:erase(k)
my_entity.resources.misc_mat.wood2.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="CEDAR") then
my_entity.resources.misc_mat.wood2.mat_type:erase(k)
my_entity.resources.misc_mat.wood2.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end
k=0
while k < #my_entity.resources.misc_mat.cages.mat_index do
v=my_entity.resources.misc_mat.cages.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.cages.mat_index[k])
if (sText==nil) then
--LIQUID cages
my_entity.resources.misc_mat.cages.mat_type:erase(k)
my_entity.resources.misc_mat.cages.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="CEDAR") then
my_entity.resources.misc_mat.cages.mat_type:erase(k)
my_entity.resources.misc_mat.cages.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end
end