v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

User:Fleeting Frames/listexoticpreferences

From Dwarf Fortress Wiki
< User:Fleeting Frames
Revision as of 23:00, 22 July 2019 by Fleeting Frames (talk | contribs) (Initial writeup)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Save as lep.lua into /hack/scripts folder.

--prints rare weapon preferences in all units.

local units = df.global.world.units.active

for i, unit in pairs (units) do
	if unit.race == df.global.ui.race_id then
		for j, preference in pairs(unit.status.current_soul.preferences) do
			if preference.type == 4 and 
			preference.item_type == 24 and 
			(preference.item_subtype == 0 or preference.item_subtype == 10 or preference.item_subtype == 12 or preference.item_subtype == 13 or preference.item_subtype == 15 or preference.item_subtype == 19 ) then
				dfhack.println(dfhack.TranslateName(dfhack.units.getVisibleName(unit)) .. " has useful preference")
			end
		end
	end
end