Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: prefchange--now with artifake working in fortress or adventurer mode!  (Read 8418 times)

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile

So I figure this is where to put it, as I said above, I looked around at a couple of scripts to figure out how to turn the all dorfs/all cleared/all same script into this one.

I think I found the "getselectedunit" bit in one from Putnam, and I poked around at a few different things before I got it working in a basic split up form, and then bit by bit was able to assemble it into a single script you can just drop in /hack/scripts:

Code: [Select]
-- Allows setting useful preferences for forcing moods
-- based on pref_adjust by vjek, version 4, 20141016, for DF(hack) 40.08, with the getselectedunit portion from a Putnam script (and the dfhack lua API but he's still a wizard)
-- turned into this hacked together version by some jerk named Max™ on the 8th of March 2015
-- updated with print all and clear all functions on the 11th of April 2015
-- Praise Armok!
-- ---------------------------------------------------------------------------
function axeplate(unit)
local unit = dfhack.gui.getSelectedUnit()

if unit==nil then
print ("No unit available!  Aborting with extreme prejudice.")
return
end

local pss_counter=31415926

local prefcount = #(unit.status.current_soul.preferences)
print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

utils = require 'utils'

-- axes and breastplates
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
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 = 0 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
-- likes steel (8)
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)
print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

end
-- ---------------------------------------------------------------------------
function hammershirt(unit)
local unit = dfhack.gui.getSelectedUnit()

if unit==nil then
print ("No unit available!  Aborting with extreme prejudice.")
return
end

local pss_counter=31415926

local prefcount = #(unit.status.current_soul.preferences)
print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

utils = require 'utils'

-- hammers and mail shirts
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 = 2 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
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')
pss_counter = pss_counter + 1
-- likes steel (8)
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)
print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

end
-- ---------------------------------------------------------------------------
function swordboot(unit)
local unit = dfhack.gui.getSelectedUnit()

if unit==nil then
print ("No unit available!  Aborting with extreme prejudice.")
return
end

local pss_counter=31415926

local prefcount = #(unit.status.current_soul.preferences)
print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

utils = require 'utils'

-- short swords and high boots
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 = 3 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.SHOES , creature_id = df.item_type.SHOES , color_id = df.item_type.SHOES , shape_id = df.item_type.SHOES , plant_id = df.item_type.SHOES , item_subtype = 1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
-- likes steel (8)
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)
print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

end
-- ---------------------------------------------------------------------------
function spearboot(unit)
local unit = dfhack.gui.getSelectedUnit()

if unit==nil then
print ("No unit available!  Aborting with extreme prejudice.")
return
end

local pss_counter=31415926

local prefcount = #(unit.status.current_soul.preferences)
print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

utils = require 'utils'

-- spears and high boots
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 = 4 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.SHOES , creature_id = df.item_type.SHOES , color_id = df.item_type.SHOES , shape_id = df.item_type.SHOES , plant_id = df.item_type.SHOES , item_subtype = 1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
-- likes steel (8)
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)
print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

end
-- ---------------------------------------------------------------------------
function maceshield(unit)
local unit = dfhack.gui.getSelectedUnit()

if unit==nil then
print ("No unit available!  Aborting with extreme prejudice.")
return
end

local pss_counter=31415926

local prefcount = #(unit.status.current_soul.preferences)
print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

utils = require 'utils'

-- maces and shields
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 = 5 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
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 = 0 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
-- likes steel (8)
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)
print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

end
-- ---------------------------------------------------------------------------
function xbowhelm(unit)
local unit = dfhack.gui.getSelectedUnit()

if unit==nil then
print ("No unit available!  Aborting with extreme prejudice.")
return
end

local pss_counter=31415926

local prefcount = #(unit.status.current_soul.preferences)
print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

utils = require 'utils'

-- crossbows and helms
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 = 6 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.HELM , creature_id = df.item_type.HELM , color_id = df.item_type.HELM , shape_id = df.item_type.HELM , plant_id = df.item_type.HELM , item_subtype = 0 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
-- likes steel (8)
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)
print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

end
-- ---------------------------------------------------------------------------
function pickglove(unit)
local unit = dfhack.gui.getSelectedUnit()

if unit==nil then
print ("No unit available!  Aborting with extreme prejudice.")
return
end

local pss_counter=31415926

local prefcount = #(unit.status.current_soul.preferences)
print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

utils = require 'utils'

-- picks and gauntlets
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 = 7 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.GLOVES  , creature_id = df.item_type.GLOVES  , color_id = df.item_type.GLOVES  , shape_id = df.item_type.GLOVES  , plant_id = df.item_type.GLOVES  , item_subtype = 0 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
-- likes steel (8)
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)
print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

end
-- ---------------------------------------------------------------------------
function longglove(unit)
local unit = dfhack.gui.getSelectedUnit()

if unit==nil then
print ("No unit available!  Aborting with extreme prejudice.")
return
end

local pss_counter=31415926

local prefcount = #(unit.status.current_soul.preferences)
print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

utils = require 'utils'

-- long swords and gauntlets, skipped bows and whatnot
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 = 13 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.GLOVES  , creature_id = df.item_type.GLOVES  , color_id = df.item_type.GLOVES  , shape_id = df.item_type.GLOVES  , plant_id = df.item_type.GLOVES  , item_subtype = 0 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
-- likes steel (8)
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)
print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

end
-- ---------------------------------------------------------------------------
function daggerpants(unit)
local unit = dfhack.gui.getSelectedUnit()

if unit==nil then
print ("No unit available!  Aborting with extreme prejudice.")
return
end

local pss_counter=31415926

local prefcount = #(unit.status.current_soul.preferences)
print ("Before, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

utils = require 'utils'

-- daggers and greaves, skipped the weapons which are too large for most dorfs
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 = 16 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
utils.insert_or_update(unit.status.current_soul.preferences, { new = true, type = 4 , item_type = df.item_type.PANTS  , creature_id = df.item_type.PANTS  , color_id = df.item_type.PANTS  , shape_id = df.item_type.PANTS  , plant_id = df.item_type.PANTS  , item_subtype = 1 , mattype = -1 , matindex = -1 , active = true, prefstring_seed = pss_counter }, 'prefstring_seed')
pss_counter = pss_counter + 1
-- likes steel (8)
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)
print ("After, unit "..dfhack.TranslateName(dfhack.units.getVisibleName(unit)).." has "..prefcount.." preferences")

end
-- ---------------------------------------------------------------------------
function print_all(v)
unit=v

local kk,vv

for kk,vv in ipairs(unit.status.current_soul.preferences) do
printall(vv)
end
end
-- ---------------------------------------------------------------------------
function clear_all(v)
unit=v

local kk,vv,unk_counter
unk_counter=31415926

for kk,vv in ipairs(unit.status.current_soul.preferences) do
vv.type = -1
vv.item_type = -1
vv.creature_id = -1
vv.color_id = -1
vv.shape_id = -1
vv.plant_id = -1
vv.item_subtype = -1
vv.mattype = -1
vv.matindex = -1
vv.active = false
vv.prefstring_seed = unk_counter
unk_counter = unk_counter + 1
end
end
-- ---------------------------------------------------------------------------
function printpref_all_dwarves()
for _,v in ipairs(df.global.world.units.active) do
if v.race == df.global.ui.race_id then
print("Showing Preferences for "..dfhack.TranslateName(dfhack.units.getVisibleName(v)))
print_all(v)
end
end
end
-- ---------------------------------------------------------------------------
function clearpref_all_dwarves()
for _,v in ipairs(df.global.world.units.active) do
if v.race == df.global.ui.race_id then
print("Clearing Preferences for "..dfhack.TranslateName(dfhack.units.getVisibleName(v)))
clear_all(v)
end
end
end
-- ---------------------------------------------------------------------------
function clear_preferences(v)
local unit = dfhack.gui.getSelectedUnit()
local prefs=unit.status.current_soul.preferences
for index,pref in ipairs(prefs) do
    pref:delete()
end
prefs:resize(0)
end
-- ---------------------------------------------------------------------------
-- main script operation starts here
-- ---------------------------------------------------------------------------
local opt = ...
local profilename

if opt then
if opt=="show" then
printpref_all_dwarves()
return
end
if opt=="c" then
clear_preferences(v)
return
end
if opt=="all" then
clearpref_all_dwarves()
return
end
if opt=="axp" then
axeplate(unit)
return
end
if opt=="has" then
hammershirt(unit)
return
end
if opt=="swb" then
swordboot(unit)
return
end
if opt=="spb" then
spearboot(unit)
return
end
if opt=="mas" then
maceshield(unit)
return
end
if opt=="xbh" then
xbowhelm(unit)
return
end
if opt=="pig" then
pickglove(unit)
return
end
if opt=="log" then
longglove(unit)
return
end
if opt=="dap" then
daggerpants(unit)
return
end
else
print ("Sets preferences for mooding to include a weapon type, equipment type, and material.")
print ("Valid options:")
print ("show -- show preferences of all units")
print ("c -- clear preferences of selected unit")
print ("all -- clear preferences of all units")
print ("axp -- likes axes, breastplates, and steel")
print ("has -- likes hammers, mail shirts, and steel")
print ("swb -- likes short swords, high boots, and steel")
print ("spb -- likes spears, high boots, and steel")
print ("mas -- likes maces, shields, and steel")
print ("xbh -- likes crossbows, helms, and steel")
print ("pig -- likes picks, gauntlets, and steel")
print ("log -- likes long swords, gauntlets, and steel")
print ("dap -- likes daggers, greaves, and steel")
print ("Feel free to adjust the values as you see fit, change the has steel to platinum, change the axp axes to great axes, whatnot.")
end
By itself: prefchange prints the help, and below that is the error message from trying "prefchange daggerpants" in the thoughts screen (though it does work with anything else that targets a unit: adventurer mode z and l, fort mode k, v, and in even the dwarf manipulator interface thanks to the awesome bit I grabbed from Putnam!)

I went with that order for pairings because that's the order they are in the item_*.txt files, though I skipped over stuff like bows and the weapons that are too large for the average dorf. Should be easy enough to alter them though since I put the smaller parts together first and then took all the axeplate.lua hammershirt.lua etc scripts and assembled them into this one, which works!

Result after using this with a unit selected: prefchange c
Spoiler (click to show/hide)

Result after using this with a unit selected: prefchange dap
Spoiler (click to show/hide)

Don't have a screenshot but I did force a mood and get a dorf to make a steel helmet after embarking and using prefchange xbh and strangemood -unit -type fey -skill armorsmith -force on them, so, I'd call it a success!

...I realized it was absurd that I had built enough muscle memory to almost go into a unit preferences and adjust them in gm-editor with my eyes closed, and now I've done gone and made a script type thingamajig!

Good lord, noticed I didn't have a space after the -- in the first comment, been wondering why it wouldn't show up for help or ls...

Added a clear all and print all function after figuring out how to work them back in without breaking everything, shortened the option names to three letter strings to be easier to type and remember.
« Last Edit: June 01, 2015, 09:27:36 pm by Max™ »
Logged

vjek

  • Bay Watcher
  • If it didn't work, change the world so it does.
    • View Profile

Very cool, nice adaptation/re-use! :)

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile

Oh good, figured you'd think it was cool, but yanno, didn't wanna step on your toes. Having a broad change for all dorfs is useful with a big fort, but doing a quick reclaim with the right stuff for forcemooding a set of artifact toys to grab on an adventurer it didn't quite work out right.

Not sure how I'd add back in the ability to apply it to all dorfs, I kept getting errors when I tried to just make yours single target until I pulled out just the parts I used for axeplate/hammershirt/etc and figured out how to reassemble them.

Very clever counter method btw, iterating the prefstring seed? I was worried how I'd do it, figured I'd need to target those individually until I really dug around in your old prefstring and new one to see what you had been doing.
« Last Edit: March 08, 2015, 11:47:22 pm by Max™ »
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile

Worth noting, it does work fine if you don't clear beforehand, but it replaces the first three preferences with a weapon/armor/material preference, so either clear first or make sure they don't overlap.

Actually used it on a dorf I wanted to force mood a gauntlet with (since they lined up in the new arrivals list conveniently, helm dorf, glove dorf, glove dorf, boot dorf, boot dorf, pants dorf, shirt dorf, plate dorf) and upon checking their preferences I saw they liked picks, gauntlets, steel, something else, steel, something else, gauntlets, and more stuff. Whoops. :D
Logged

Snergler

  • Bay Watcher
  • The world is the same as ever.
    • View Profile

very cool, I wanted to add a "by unit" option to vjek's pref-adjust script myself, but could not figure it out. I was just thinking about a thread for modding dfhack script. I modded the create-item script, so it has a few more options, I can't find who origanly wrote it, so I did not want to post mine, without giving the creater their credit... but here it is if your interested... it's a ruby script so I called it "make.rb"
Spoiler (click to show/hide)

I find it helpfull for testing new custom reactions quickly in fortress mode 
« Last Edit: March 09, 2015, 08:28:59 pm by Snergler »
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile

Ah, cool, like a command line version of hack-wish except you don't need a unit to target? I can see how that could be handy for a lot of stuff.

I was hoping there would be an easier way to add it in to vjeks script but figured I'd post this since I had to take it apart into chunks and then figure out how to get them reassembled without throwing errors at me constantly. Though that is why I made sure to point out that vjek did the actual work, I just cut and pasted until I got the order right. :D
Logged

Snergler

  • Bay Watcher
  • The world is the same as ever.
    • View Profile

basicaly for items with no quality level, like build materials, although I don't think the format is limited to that, I just can't figure out the syntax for declairing items with subtypes. anvils just come out base quality, i don't know if its possible to declare a quality in that format. I think the creation of the item is to"an unknown artist" , so hack-wish is still more sophisticated, but I don't think you can specify a quantity, and items like armor, gloves, shoes, etc... that i create with hack-wish don't seem to show up in the squad/equip/specific.. menu       
« Last Edit: March 09, 2015, 09:13:17 pm by Snergler »
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile

I have not been able to get hack-wish to respond properly regarding the quality of items, and have you tried your script with a unit targeted to see if it assigns them as the maker?

Wait, your stuff becomes available for military assignment without first designating it to be dumped/unforbidding it (the old workaround I used for createitem'D stuff) then having it stockpiled?

Also: I'm gonna kill you for putting that damn song in my head.
« Last Edit: March 09, 2015, 09:27:29 pm by Max™ »
Logged

Snergler

  • Bay Watcher
  • The world is the same as ever.
    • View Profile

the create-items and my modded version won't assign creatorship, even with a unit selected unfortunatly. It's always an unknown artisan,  but the item is considerd native to your fortress (not imported). your right about hack-wish though, the quality level option does not seem to work for me, its always base. I think your right about having to put armor and stuff in stockpiles before it is recognized as available for squad assignment too. I've had that happen with regular "reaction created" armor before also. thanks for the help and the script, I pasted the "get selected unit" lines into my own mode of that script and it works great :)   

I felt the song would build up the anticipation for the next release, but it's probably not quit what Toadyone has in mind for it :P
« Last Edit: March 09, 2015, 09:41:03 pm by Snergler »
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile

Well, thank Putnam as I stole it from one of his scripts, remove-stress.lua to be exact, was looking at what I did and that was the one where it jumped out to me that it was exactly what I needed.
« Last Edit: March 09, 2015, 10:22:26 pm by Max™ »
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile

hack-wish should assign quality properly in the next DFHack release, IIRC. I found the problem there, at least, and fixed at least one problem with hack-wish.

You really shouldn't be crediting me for the getSelectedUnit() thing, since it's part of the API...

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile

Just meant I got the idea to use it from seeing your use of it, so even though it might not be 'your' code it was one of your scripts that had the piece I needed to finally get a working but limited bit of script, which then allowed me to insert the standalone bits back into vjek's opt layout, so I feel a bit obligated to note where I got it from. if anything it seems like it would be more common since it trims a lot of extra code into the one line

Hmmm, didn't even realize I could check the api for that. I've never tried to do anything with modifying scripts or whatnot directly Just struck me that it would hopefully take less time to figure out how to make it work than I spend just doing a couple of tweaked preference sets.

Well I definitely feel more "wizard's apprentice"-y after looking through there, I'll say that much.

Oh yeah, this took the time required to select the units, type the two lines, and wait for them to finish their moods:

Breastplate, Mail Shirt, Greaves, Left/Right Gauntlets, Helm, High Boots, War Hammer, Battle Axe, Shield. Sooooo much easier than doing it in gm-editor per unit for a set of adventurer toys.
« Last Edit: March 10, 2015, 12:43:04 pm by Max™ »
Logged

StagnantSoul

  • Bay Watcher
  • "Player has withdrawn from society!"
    • View Profile

How do I put it in there? Just wondering.
Logged
Quote from: Cptn Kaladin Anrizlokum
I threw night creature blood into a night creature's heart and she pulled it out and bled to death.
Quote from: Eric Blank
Places to jibber madly at each other, got it
Quote from: NJW2000
If any of them are made of fire, throw stuff, run, and think non-flammable thoughts.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile

Oh, I just saved it in the scripts folder as prefchange.lua I would put it on a github page or something but I don't have one

To switch materials, I think you mentioned burning steel, that's probably after adamantine in the inorganic_metals right? So just swap the item_subtype = 8 to 26 or whichever one it is in order and it'll work fine.
Logged

StagnantSoul

  • Bay Watcher
  • "Player has withdrawn from society!"
    • View Profile

Thanks!
Logged
Quote from: Cptn Kaladin Anrizlokum
I threw night creature blood into a night creature's heart and she pulled it out and bled to death.
Quote from: Eric Blank
Places to jibber madly at each other, got it
Quote from: NJW2000
If any of them are made of fire, throw stuff, run, and think non-flammable thoughts.
Pages: [1] 2