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.

Difference between revisions of "User:Fleeting Frames/listexoticpreferences"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
(Initial writeup)
 
m (soul check)
 
Line 7: Line 7:
  
 
for i, unit in pairs (units) do
 
for i, unit in pairs (units) do
if unit.race == df.global.ui.race_id then
+
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
 
for j, preference in pairs(unit.status.current_soul.preferences) do
 
if preference.type == 4 and  
 
if preference.type == 4 and  

Latest revision as of 18:01, 20 August 2019

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