Fix indentation in Vjek scripts.

develop
expwnent 2015-09-21 18:18:48 -04:00
parent 93ce64a32c
commit cb0591f315
6 changed files with 203 additions and 204 deletions

@ -5,14 +5,13 @@
-- by vjek -- by vjek
function rejuvenate(unit) function rejuvenate(unit)
if unit==nil then if unit==nil then
print ("No unit available! Aborting with extreme prejudice.") print ("No unit available! Aborting with extreme prejudice.")
return return
end end
local current_year=df.global.cur_year local current_year=df.global.cur_year
local newbirthyear=current_year - 20 local newbirthyear=current_year - 20
if unit.relations.birth_year < newbirthyear then if unit.relations.birth_year < newbirthyear then
unit.relations.birth_year=newbirthyear unit.relations.birth_year=newbirthyear
end end
@ -28,12 +27,12 @@ function brainwash_unit(unit)
return return
end end
local profile ={75,25,25,75,25,25,25,99,25,25,25,50,75,50,25,75,75,50,75,75,25,75,75,50,75,25,50,25,75,75,75,25,75,75,25,75,25,25,75,75,25,75,75,75,25,75,75,25,25,50} local profile ={75,25,25,75,25,25,25,99,25,25,25,50,75,50,25,75,75,50,75,75,25,75,75,50,75,25,50,25,75,75,75,25,75,75,25,75,25,25,75,75,25,75,75,75,25,75,75,25,25,50}
local i local i
for i=1, #profile do for i=1, #profile do
unit.status.current_soul.personality.traits[i-1]=profile[i] unit.status.current_soul.personality.traits[i-1]=profile[i]
end end
end end
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
@ -43,14 +42,14 @@ function elevate_attributes(unit)
return return
end end
local ok,f,t,k = pcall(pairs,unit.status.current_soul.mental_attrs) local ok,f,t,k = pcall(pairs,unit.status.current_soul.mental_attrs)
if ok then if ok then
for k,v in f,t,k do for k,v in f,t,k do
v.value=v.max_value v.value=v.max_value
end end
end end
local ok,f,t,k = pcall(pairs,unit.body.physical_attrs) local ok,f,t,k = pcall(pairs,unit.body.physical_attrs)
if ok then if ok then
for k,v in f,t,k do for k,v in f,t,k do
v.value=v.max_value v.value=v.max_value
@ -61,18 +60,18 @@ end
-- this function will return the number of elements, starting at zero. -- this function will return the number of elements, starting at zero.
-- useful for counting things where #foo doesn't work -- useful for counting things where #foo doesn't work
function count_this(to_be_counted) function count_this(to_be_counted)
local count = -1 local count = -1
local var1 = "" local var1 = ""
while var1 ~= nil do while var1 ~= nil do
count = count + 1 count = count + 1
var1 = (to_be_counted[count]) var1 = (to_be_counted[count])
end end
count=count-1 count=count-1
return count return count
end end
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
function make_legendary(skillname,unit) function make_legendary(skillname,unit)
local skillnamenoun,skillnum local skillnamenoun,skillnum
if unit==nil then if unit==nil then
print ("No unit available! Aborting with extreme prejudice.") print ("No unit available! Aborting with extreme prejudice.")
@ -103,53 +102,53 @@ function BreathOfArmok(unit)
print ("No unit available! Aborting with extreme prejudice.") print ("No unit available! Aborting with extreme prejudice.")
return return
end end
local i local i
local count_max = count_this(df.job_skill) local count_max = count_this(df.job_skill)
utils = require 'utils' utils = require 'utils'
for i=0, count_max do for i=0, count_max do
utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = i, rating = 20 }, 'id') utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = i, rating = 20 }, 'id')
end end
print ("The breath of Armok has engulfed "..unit.name.first_name) print ("The breath of Armok has engulfed "..unit.name.first_name)
end end
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
function LegendaryByClass(skilltype,v) function LegendaryByClass(skilltype,v)
unit=v unit=v
if unit==nil then if unit==nil then
print ("No unit available! Aborting with extreme prejudice.") print ("No unit available! Aborting with extreme prejudice.")
return return
end end
utils = require 'utils' utils = require 'utils'
local i local i
local skillclass local skillclass
local count_max = count_this(df.job_skill) local count_max = count_this(df.job_skill)
for i=0, count_max do for i=0, count_max do
skillclass = df.job_skill_class[df.job_skill.attrs[i].type] skillclass = df.job_skill_class[df.job_skill.attrs[i].type]
if skilltype == skillclass then if skilltype == skillclass then
print ("Skill "..df.job_skill.attrs[i].caption.." is type: "..skillclass.." and is now Legendary for "..unit.name.first_name) print ("Skill "..df.job_skill.attrs[i].caption.." is type: "..skillclass.." and is now Legendary for "..unit.name.first_name)
utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = i, rating = 20 }, 'id') utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = i, rating = 20 }, 'id')
end end
end end
end end
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
function PrintSkillList() function PrintSkillList()
local count_max = count_this(df.job_skill) local count_max = count_this(df.job_skill)
local i local i
for i=0, count_max do for i=0, count_max do
print("'"..df.job_skill.attrs[i].caption.."' "..df.job_skill[i].." Type: "..df.job_skill_class[df.job_skill.attrs[i].type]) print("'"..df.job_skill.attrs[i].caption.."' "..df.job_skill[i].." Type: "..df.job_skill_class[df.job_skill.attrs[i].type])
end end
print ("Provide the UPPER CASE argument, for example: PROCESSPLANTS rather than Threshing") print ("Provide the UPPER CASE argument, for example: PROCESSPLANTS rather than Threshing")
end end
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
function PrintSkillClassList() function PrintSkillClassList()
local i local i
local count_max = count_this(df.job_skill_class) local count_max = count_this(df.job_skill_class)
for i=0, count_max do for i=0, count_max do
print(df.job_skill_class[i]) print(df.job_skill_class[i])
end end
print ("Provide one of these arguments, and all skills of that type will be made Legendary") print ("Provide one of these arguments, and all skills of that type will be made Legendary")
print ("For example: Medical will make all medical skills legendary") print ("For example: Medical will make all medical skills legendary")
end end
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
function adjust_all_dwarves(skillname) function adjust_all_dwarves(skillname)
@ -189,6 +188,6 @@ if opt then
skillname = opt skillname = opt
else else
print ("No skillname supplied, no skills will be adjusted. Pass argument 'list' to see a skill list, 'classes' to show skill classes, or use 'all' if you want all skills legendary.") print ("No skillname supplied, no skills will be adjusted. Pass argument 'list' to see a skill list, 'classes' to show skill classes, or use 'all' if you want all skills legendary.")
end end
adjust_all_dwarves(skillname) adjust_all_dwarves(skillname)

@ -3,27 +3,27 @@
-- by vjek -- by vjek
function brainwash_unit(profile) function brainwash_unit(profile)
local i,unit_name local i,unit_name
unit=dfhack.gui.getSelectedUnit() unit=dfhack.gui.getSelectedUnit()
if unit==nil then if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.") print ("No unit under cursor! Aborting with extreme prejudice.")
return return
end end
unit_name=dfhack.TranslateName(dfhack.units.getVisibleName(unit)) unit_name=dfhack.TranslateName(dfhack.units.getVisibleName(unit))
print("Previous personality values for "..unit_name) print("Previous personality values for "..unit_name)
printall(unit.status.current_soul.personality.traits) printall(unit.status.current_soul.personality.traits)
--now set new personality --now set new personality
for i=1, #profile do for i=1, #profile do
unit.status.current_soul.personality.traits[i-1]=profile[i] unit.status.current_soul.personality.traits[i-1]=profile[i]
end end
print("New personality values for "..unit_name) print("New personality values for "..unit_name)
printall(unit.status.current_soul.personality.traits) printall(unit.status.current_soul.personality.traits)
print(unit_name.." has been brainwashed, praise Armok!") print(unit_name.." has been brainwashed, praise Armok!")
end end
-- main script starts here -- main script starts here
@ -39,19 +39,19 @@ if opt then
if opt=="ideal" then if opt=="ideal" then
brainwash_unit(ideal) brainwash_unit(ideal)
return return
end end
if opt=="baseline" then if opt=="baseline" then
brainwash_unit(baseline) brainwash_unit(baseline)
return return
end end
if opt=="stepford" then if opt=="stepford" then
brainwash_unit(stepford) brainwash_unit(stepford)
return return
end end
if opt=="wrecked" then if opt=="wrecked" then
brainwash_unit(wrecked) brainwash_unit(wrecked)
return return
end end
else else
print ("Invalid or missing personality argument.\nValid choices are ideal , baseline , stepford, and wrecked.") print ("Invalid or missing personality argument.\nValid choices are ideal , baseline , stepford, and wrecked.")
print ("ideal will create a reliable dwarf with generally positive personality traits.") print ("ideal will create a reliable dwarf with generally positive personality traits.")

@ -4,25 +4,25 @@
-- by vjek -- by vjek
function ElevateMentalAttributes(value) function ElevateMentalAttributes(value)
unit=dfhack.gui.getSelectedUnit() unit=dfhack.gui.getSelectedUnit()
if unit==nil then if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.") print ("No unit under cursor! Aborting with extreme prejudice.")
return return
end end
--print name of dwarf --print name of dwarf
print("Adjusting "..dfhack.TranslateName(dfhack.units.getVisibleName(unit))) print("Adjusting "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)))
--walk through available attributes, adjust current to max --walk through available attributes, adjust current to max
local ok,f,t,k = pcall(pairs,unit.status.current_soul.mental_attrs) local ok,f,t,k = pcall(pairs,unit.status.current_soul.mental_attrs)
if ok then if ok then
for k,v in f,t,k do for k,v in f,t,k do
if value ~= nil then if value ~= nil then
print("Adjusting current value for "..tostring(k).." of "..v.value.." to the value of "..value) print("Adjusting current value for "..tostring(k).." of "..v.value.." to the value of "..value)
v.value=value v.value=value
else else
print("Adjusting current value for "..tostring(k).." of "..v.value.." to max value of "..v.max_value) print("Adjusting current value for "..tostring(k).." of "..v.value.." to max value of "..v.max_value)
v.value=v.max_value v.value=v.max_value
--below will reset values back to "normal" --below will reset values back to "normal"
--v.value=v.max_value/2 --v.value=v.max_value/2
end end
end end
end end

@ -4,25 +4,25 @@
-- by vjek -- by vjek
function ElevatePhysicalAttributes(value) function ElevatePhysicalAttributes(value)
unit=dfhack.gui.getSelectedUnit() unit=dfhack.gui.getSelectedUnit()
if unit==nil then if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.") print ("No unit under cursor! Aborting with extreme prejudice.")
return return
end end
--print name of dwarf --print name of dwarf
print("Adjusting "..dfhack.TranslateName(dfhack.units.getVisibleName(unit))) print("Adjusting "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)))
--walk through available attributes, adjust current to max --walk through available attributes, adjust current to max
local ok,f,t,k = pcall(pairs,unit.body.physical_attrs) local ok,f,t,k = pcall(pairs,unit.body.physical_attrs)
if ok then if ok then
for k,v in f,t,k do for k,v in f,t,k do
if value ~= nil then if value ~= nil then
print("Adjusting current value for "..tostring(k).." of "..v.value.." to the value of "..value) print("Adjusting current value for "..tostring(k).." of "..v.value.." to the value of "..value)
v.value=value v.value=value
else else
print("Adjusting current value for "..tostring(k).." of "..v.value.." to max value of "..v.max_value) print("Adjusting current value for "..tostring(k).." of "..v.value.." to max value of "..v.max_value)
v.value=v.max_value v.value=v.max_value
--below will reset values back to "normal" --below will reset values back to "normal"
--v.value=v.max_value/2 --v.value=v.max_value/2
end end
end end
end end

@ -7,95 +7,95 @@
-- this function will return the number of elements, starting at zero. -- this function will return the number of elements, starting at zero.
-- useful for counting things where #foo doesn't work -- useful for counting things where #foo doesn't work
function count_this(to_be_counted) function count_this(to_be_counted)
local count = -1 local count = -1
local var1 = "" local var1 = ""
while var1 ~= nil do while var1 ~= nil do
count = count + 1 count = count + 1
var1 = (to_be_counted[count]) var1 = (to_be_counted[count])
end end
count=count-1 count=count-1
return count return count
end end
function make_legendary(skillname) function make_legendary(skillname)
local skillnamenoun,skillnum local skillnamenoun,skillnum
unit=dfhack.gui.getSelectedUnit() unit=dfhack.gui.getSelectedUnit()
if unit==nil then if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.") print ("No unit under cursor! Aborting with extreme prejudice.")
return return
end end
if (df.job_skill[skillname]) then if (df.job_skill[skillname]) then
skillnamenoun = df.job_skill.attrs[df.job_skill[skillname]].caption_noun skillnamenoun = df.job_skill.attrs[df.job_skill[skillname]].caption_noun
else else
print ("The skill name provided is not in the list.") print ("The skill name provided is not in the list.")
return return
end end
if skillnamenoun ~= nil then if skillnamenoun ~= nil then
utils = require 'utils' utils = require 'utils'
skillnum = df.job_skill[skillname] skillnum = df.job_skill[skillname]
utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = skillnum, rating = 20 }, 'id') utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = skillnum, rating = 20 }, 'id')
print (dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." is now a Legendary "..skillnamenoun) print (dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." is now a Legendary "..skillnamenoun)
else else
print ("Empty skill name noun, bailing out!") print ("Empty skill name noun, bailing out!")
return return
end end
end end
function PrintSkillList() function PrintSkillList()
local count_max = count_this(df.job_skill) local count_max = count_this(df.job_skill)
local i local i
for i=0, count_max do for i=0, count_max do
print("'"..df.job_skill.attrs[i].caption.."' "..df.job_skill[i].." Type: "..df.job_skill_class[df.job_skill.attrs[i].type]) print("'"..df.job_skill.attrs[i].caption.."' "..df.job_skill[i].." Type: "..df.job_skill_class[df.job_skill.attrs[i].type])
end end
print ("Provide the UPPER CASE argument, for example: PROCESSPLANTS rather than Threshing") print ("Provide the UPPER CASE argument, for example: PROCESSPLANTS rather than Threshing")
end end
function BreathOfArmok() function BreathOfArmok()
unit=dfhack.gui.getSelectedUnit() unit=dfhack.gui.getSelectedUnit()
if unit==nil then if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.") print ("No unit under cursor! Aborting with extreme prejudice.")
return return
end end
local i local i
local count_max = count_this(df.job_skill) local count_max = count_this(df.job_skill)
utils = require 'utils' utils = require 'utils'
for i=0, count_max do for i=0, count_max do
utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = i, rating = 20 }, 'id') utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = i, rating = 20 }, 'id')
end end
print ("The breath of Armok has engulfed "..dfhack.TranslateName(dfhack.units.getVisibleName(unit))) print ("The breath of Armok has engulfed "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)))
end end
function LegendaryByClass(skilltype) function LegendaryByClass(skilltype)
unit=dfhack.gui.getSelectedUnit() unit=dfhack.gui.getSelectedUnit()
if unit==nil then if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.") print ("No unit under cursor! Aborting with extreme prejudice.")
return return
end end
utils = require 'utils' utils = require 'utils'
local i local i
local skillclass local skillclass
local count_max = count_this(df.job_skill) local count_max = count_this(df.job_skill)
for i=0, count_max do for i=0, count_max do
skillclass = df.job_skill_class[df.job_skill.attrs[i].type] skillclass = df.job_skill_class[df.job_skill.attrs[i].type]
if skilltype == skillclass then if skilltype == skillclass then
print ("Skill "..df.job_skill.attrs[i].caption.." is type: "..skillclass.." and is now Legendary for "..dfhack.TranslateName(dfhack.units.getVisibleName(unit))) print ("Skill "..df.job_skill.attrs[i].caption.." is type: "..skillclass.." and is now Legendary for "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)))
utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = i, rating = 20 }, 'id') utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = i, rating = 20 }, 'id')
end end
end end
end end
function PrintSkillClassList() function PrintSkillClassList()
local i local i
local count_max = count_this(df.job_skill_class) local count_max = count_this(df.job_skill_class)
for i=0, count_max do for i=0, count_max do
print(df.job_skill_class[i]) print(df.job_skill_class[i])
end end
print ("Provide one of these arguments, and all skills of that type will be made Legendary") print ("Provide one of these arguments, and all skills of that type will be made Legendary")
print ("For example: Medical will make all medical skills legendary") print ("For example: Medical will make all medical skills legendary")
end end
--main script operation starts here --main script operation starts here
@ -107,24 +107,24 @@ if opt then
if opt=="list" then if opt=="list" then
PrintSkillList() PrintSkillList()
return return
end end
if opt=="classes" then if opt=="classes" then
PrintSkillClassList() PrintSkillClassList()
return return
end end
if opt=="all" then if opt=="all" then
BreathOfArmok() BreathOfArmok()
return return
end end
if opt=="Normal" or opt=="Medical" or opt=="Personal" or opt=="Social" or opt=="Cultural" or opt=="MilitaryWeapon" or opt=="MilitaryAttack" or opt=="MilitaryDefense" or opt=="MilitaryMisc" then if opt=="Normal" or opt=="Medical" or opt=="Personal" or opt=="Social" or opt=="Cultural" or opt=="MilitaryWeapon" or opt=="MilitaryAttack" or opt=="MilitaryDefense" or opt=="MilitaryMisc" then
LegendaryByClass(opt) LegendaryByClass(opt)
return return
end end
skillname = opt skillname = opt
else else
print ("No skillname supplied.\nUse argument 'list' to see a list, 'classes' to show skill classes, or use 'all' if you want it all!") print ("No skillname supplied.\nUse argument 'list' to see a list, 'classes' to show skill classes, or use 'all' if you want it all!")
print ("Example: To make a legendary miner, use make_legendary MINING") print ("Example: To make a legendary miner, use make_legendary MINING")
return return
end end
make_legendary(skillname) make_legendary(skillname)

@ -11,61 +11,61 @@ function brainwash_unit(unit)
return return
end end
local pss_counter=31415926 local pss_counter=31415926
local prefcount = #(unit.status.current_soul.preferences) local prefcount = #(unit.status.current_soul.preferences)
print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences") print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")
utils = require 'utils' utils = require 'utils'
-- below populates an array with all creature names and id's, used for 'detests...' -- below populates an array with all creature names and id's, used for 'detests...'
rtbl={} rtbl={}
vec=df.global.world.raws.creatures.all vec=df.global.world.raws.creatures.all
for k=0,#vec-1 do for k=0,#vec-1 do
local name=vec[k].creature_id local name=vec[k].creature_id
rtbl[name]=k rtbl[name]=k
end end
-- Now iterate through for the type 3 detests... -- Now iterate through for the type 3 detests...
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 3 , item_type = rtbl.TROLL , creature_id = rtbl.TROLL , color_id = rtbl.TROLL , shape_id = rtbl.TROLL , plant_id = rtbl.TROLL , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 3 , item_type = rtbl.TROLL , creature_id = rtbl.TROLL , color_id = rtbl.TROLL , shape_id = rtbl.TROLL , plant_id = rtbl.TROLL , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1 pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 3 , item_type = rtbl.BIRD_BUZZARD , creature_id = rtbl.BIRD_BUZZARD , color_id = rtbl.BIRD_BUZZARD , shape_id = rtbl.BIRD_BUZZARD , plant_id = rtbl.BIRD_BUZZARD , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 3 , item_type = rtbl.BIRD_BUZZARD , creature_id = rtbl.BIRD_BUZZARD , color_id = rtbl.BIRD_BUZZARD , shape_id = rtbl.BIRD_BUZZARD , plant_id = rtbl.BIRD_BUZZARD , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1 pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 3 , item_type = rtbl.BIRD_VULTURE , creature_id = rtbl.BIRD_VULTURE , color_id = rtbl.BIRD_VULTURE , shape_id = rtbl.BIRD_VULTURE , plant_id = rtbl.BIRD_VULTURE , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 3 , item_type = rtbl.BIRD_VULTURE , creature_id = rtbl.BIRD_VULTURE , color_id = rtbl.BIRD_VULTURE , shape_id = rtbl.BIRD_VULTURE , plant_id = rtbl.BIRD_VULTURE , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1 pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 3 , item_type = rtbl.CRUNDLE , creature_id = rtbl.CRUNDLE , color_id = rtbl.CRUNDLE , shape_id = rtbl.CRUNDLE , plant_id = rtbl.CRUNDLE , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 3 , item_type = rtbl.CRUNDLE , creature_id = rtbl.CRUNDLE , color_id = rtbl.CRUNDLE , shape_id = rtbl.CRUNDLE , plant_id = rtbl.CRUNDLE , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1 pss_counter = pss_counter + 1
-- and the type 4 likes -- and the type 4 likes
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.WEAPON , creature_id = df.item_type.WEAPON , color_id = df.item_type.WEAPON , shape_id = df.item_type.WEAPON , plant_id = df.item_type.WEAPON , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.WEAPON , creature_id = df.item_type.WEAPON , color_id = df.item_type.WEAPON , shape_id = df.item_type.WEAPON , plant_id = df.item_type.WEAPON , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1 pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.ARMOR , creature_id = df.item_type.ARMOR , color_id = df.item_type.ARMOR , shape_id = df.item_type.ARMOR , plant_id = df.item_type.ARMOR , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.ARMOR , creature_id = df.item_type.ARMOR , color_id = df.item_type.ARMOR , shape_id = df.item_type.ARMOR , plant_id = df.item_type.ARMOR , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1 pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.SHIELD , creature_id = df.item_type.SHIELD , color_id = df.item_type.SHIELD , shape_id = df.item_type.SHIELD , plant_id = df.item_type.SHIELD , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.SHIELD , creature_id = df.item_type.SHIELD , color_id = df.item_type.SHIELD , shape_id = df.item_type.SHIELD , plant_id = df.item_type.SHIELD , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1 pss_counter = pss_counter + 1
-- prefers plump helmets for their ... -- prefers plump helmets for their ...
local ph_mat_type=dfhack.matinfo.find("MUSHROOM_HELMET_PLUMP:STRUCTURAL").index local ph_mat_type=dfhack.matinfo.find("MUSHROOM_HELMET_PLUMP:STRUCTURAL").index
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 5 , item_type = ph_mat_type , creature_id = ph_mat_type , color_id = ph_mat_type , shape_id = ph_mat_type , plant_id = ph_mat_type , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 5 , item_type = ph_mat_type , creature_id = ph_mat_type , color_id = ph_mat_type , shape_id = ph_mat_type , plant_id = ph_mat_type , item_subtype = -1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1 pss_counter = pss_counter + 1
-- prefers to consume dwarven wine: -- prefers to consume dwarven wine:
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 2 , item_type = 68 , creature_id = 68 , color_id = 68 , shape_id = 68 , plant_id = 68 , item_subtype = -1 , mattype = dfhack.matinfo.find("MUSHROOM_HELMET_PLUMP:DRINK").type , matindex = dfhack.matinfo.find("MUSHROOM_HELMET_PLUMP:DRINK").index , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 2 , item_type = 68 , creature_id = 68 , color_id = 68 , shape_id = 68 , plant_id = 68 , item_subtype = -1 , mattype = dfhack.matinfo.find("MUSHROOM_HELMET_PLUMP:DRINK").type , matindex = dfhack.matinfo.find("MUSHROOM_HELMET_PLUMP:DRINK").index , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1 pss_counter = pss_counter + 1
-- likes iron, steel (0,8) adam is 25 -- likes iron, steel (0,8) adam is 25
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 0 , item_type = -1 , creature_id = -1 , color_id = -1 , shape_id = -1 , plant_id = -1 , item_subtype = -1 , mattype = 0 , matindex = dfhack.matinfo.find("IRON").index , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 0 , item_type = -1 , creature_id = -1 , color_id = -1 , shape_id = -1 , plant_id = -1 , item_subtype = -1 , mattype = 0 , matindex = dfhack.matinfo.find("IRON").index , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1 pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 0 , item_type = -1 , creature_id = -1 , color_id = -1 , shape_id = -1 , plant_id = -1 , item_subtype = -1 , mattype = 0 , matindex = dfhack.matinfo.find("STEEL").index , active = true, prefstring_seed = pss_counter }, 'prefstring_seed') utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 0 , item_type = -1 , creature_id = -1 , color_id = -1 , shape_id = -1 , plant_id = -1 , item_subtype = -1 , mattype = 0 , matindex = dfhack.matinfo.find("STEEL").index , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
prefcount = #(unit.status.current_soul.preferences) prefcount = #(unit.status.current_soul.preferences)
print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences") print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")
end end
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
function clear_preferences(v) function clear_preferences(v)
unit=v unit=v
local prefs=unit.status.current_soul.preferences local prefs=unit.status.current_soul.preferences
for index,pref in ipairs(prefs) do for index,pref in ipairs(prefs) do
pref:delete() pref:delete()
end end
prefs:resize(0) prefs:resize(0)
end end
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
function clearpref_all_dwarves() function clearpref_all_dwarves()
@ -73,8 +73,8 @@ function clearpref_all_dwarves()
if v.race == df.global.ui.race_id then if v.race == df.global.ui.race_id then
print("Clearing Preferences for "..dfhack.TranslateName(dfhack.units.getVisibleName(v))) print("Clearing Preferences for "..dfhack.TranslateName(dfhack.units.getVisibleName(v)))
clear_preferences(v) clear_preferences(v)
end
end end
end
end end
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
function adjust_all_dwarves() function adjust_all_dwarves()
@ -82,8 +82,8 @@ function adjust_all_dwarves()
if v.race == df.global.ui.race_id then if v.race == df.global.ui.race_id then
print("Adjusting "..dfhack.TranslateName(dfhack.units.getVisibleName(v))) print("Adjusting "..dfhack.TranslateName(dfhack.units.getVisibleName(v)))
brainwash_unit(v) brainwash_unit(v)
end
end end
end
end end
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
-- main script operation starts here -- main script operation starts here