User:Fleeting Frames/listexoticpreferences

From Dwarf Fortress Wiki
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 and unit.status.current_soul 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