Hey everyone, I stumbled upon a little problem. I am sure there is a simple solution for it, I just dont know it yet. I have this nice script that Urist da Vinci wrote, its actually two scripts. The first one shows the access of a civ to a specific material, this example show all wood types. The second one removes all items, crafts, barrels and so forth, of a specific wood.
wood.lua => Shows the tree_id of accessable wood.
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
nosporewood.lua => Removes access to sporewood from your civ. No more sporewood at embark or from traders.
removes all SPORE_TREE wood from all civs:
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=="SPORE_TREE") 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=="SPORE_TREE") 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=="SPORE_TREE") 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=="SPORE_TREE") 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=="SPORE_TREE") 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
The problem that arises is that the user must run it manually. I can add "nosporewood" to the dfhack.init, but it does not work. The script, just like embark everywhere or startdwarf, has to be run at the embark screen, on the map before you press 'e' and get to your embark selection. The quesion I have is: Can this be automated? Are there any lines that can be added so that the script is run every time the embark screen is opened?
And if yes, would a small pop-up/ui be possible? It would be nice if a player would start DF, go to the embark selection, and a little pop-up shows with "With how many citizens would you like to embark? (min-7)" and the player could add a number, press enter, and thats it. Just to make the startdwarf script a bit more accessable.
Background info, for those who care: Evaporating wood can be done, and can affect woodcutter with syndromes. But you cant use it on the surface or in the caverns, because these wood types are stable in worldgen, so caravans will bring wagons, barrels and items made of those materials. They then instantly boil away, affecting the trader with the syndrome. If I remove these with a script from the traders, I can make syndrome-bearing trees... good with positive effects, evil with negative effects.. a firestarting-tree for deserts, poisonous gas-clouds from giant underground mushrooms, and so forth.
Which leads to question number 3: The script only removes it from your home-civ, if I am not wrong. Which means that allies, like elves, would still bring these evaporating wood types. I would need a variant of this script that targets all civs. I assume its just changing the my_entity. with something else, but I dont know lua. One for creatures/pets would be even more helpful. It would be a lot easier to assign specific domestic pets to specific races, which is a major point in MasterworkDF, because of the multiple playable races. It even leads to some bugs, because I have to remove and add several creatures, depending on which race you play.
I also found this script while reading through custom ones that have been posted:
MEDIC.RB. Mark unit as requiring a medic.
# Mark a unit as requiring a medic
selected = df.unit_find()
if selected == nil
puts "You must select a dwarf first"
else
puts "Marking '#{selected.name}' as needing a medic"
selected.health.flags.rq_diagnosis = true
selected.health.flags.needs_healthcare = true
# This is normally set if dwarf can't walk,
selected.health.flags.needs_recovery = true
end
As far as I understand it you look at a dwarf with 'k', then run the script, and the job-priority for diagnosis and rescue go up. So if an injured dwarf is lying, ignored, on a battlefield, or the chief medical dwarf is for some reason not diagnosing a patient in the hospital, then this script will help?
To sum it up:
#1: Can a script be automatically run once the embark screen/map opens?
#2: Can this script open a small pop-up that accepts a number as entry, for the startdwarf.rb script?
#3: Could someone please be so kind (if #1 has a yes as answer), to change the script to target all civs, instead of just the players civ?
#4: Can the above-shown scripts be altered to show/erase available creatures/pets?
#5: Does anyone have experience with the medic.rb script and could give a short readme for it?