Created
October 21, 2015 20:56
-
-
Save warmist/de0b8f94b6e6c53344e0 to your computer and use it in GitHub Desktop.
Makes item to use historical name of material. E.g. titan's name instead of "titan leather"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local figure_base=219 | |
local creature_base=19 | |
function is_already_historical( it ) | |
return it:getMaterial()>=figure_base | |
end | |
function find_hf_by_race(race,unique) | |
local hfl=df.global.world.history.figures | |
local found | |
for i,v in ipairs(hfl) do | |
if v.race==race then | |
if found then | |
qerror("Historical figure with this race is not unique") | |
end | |
found=v | |
if not unique then return found end | |
end | |
end | |
return found | |
end | |
function chage_mat_figure(item,fig_id ) | |
local mat=item:getActualMaterial() | |
local mat_idx=item:getActualMaterialIndex() | |
item:setMaterial(figure_base+mat-creature_base) | |
item:setMaterialIndex(fig_id) | |
end | |
local trg=dfhack.gui.getSelectedItem() | |
if is_already_historical(trg) then | |
qerror("Item already figure-based") | |
else | |
local race=trg:getActualMaterialIndex() | |
local hf=find_hf_by_race(race,true) | |
if hf==nil then | |
qerror("No valid hist-figure found") | |
end | |
chage_mat_figure(trg,hf.id) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment