I'm trying to do a thing, but I'm terrible and I can't figure out what's wrong.
What I want to make happen is that nobody trades with clay anymore, elves in particular. UristdaVinci's blood-del script already crawls entity resource lists and purges all mentions of blood and other useless extracts, so I thought I'd repurpose that, but it seems I can't just make the script look in "misc_mat.clay" instead of "misc_mat.extracts" instead.
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.misc_mat.clay.mat_index do
v=my_entity.resources.misc_mat.clay.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.clay.mat_index[k])
if (sText==nil) then
my_entity.resources.misc_mat.clay.mat_type:erase(k)
my_entity.resources.misc_mat.clay.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="CLAY") then
my_entity.resources.misc_mat.clay.mat_type:erase(k)
my_entity.resources.misc_mat.clay.mat_index:erase(k)
k=k-1
end
if(sText.material.id=="SANDY_CLAY") then
my_entity.resources.misc_mat.clay.mat_type:erase(k)
my_entity.resources.misc_mat.clay.mat_index:erase(k)
k=k-1
end
if(sText.material.id=="SILTY_CLAY") then
my_entity.resources.misc_mat.clay.mat_type:erase(k)
my_entity.resources.misc_mat.clay.mat_index:erase(k)
k=k-1
end
if(sText.material.id=="CLAY_LOAM") then
my_entity.resources.misc_mat.clay.mat_type:erase(k)
my_entity.resources.misc_mat.clay.mat_index:erase(k)
k=k-1
end
end
k=k+1
end
end
This was my crude attempt. What do?