support searching for spheres on the religion selector

develop
Myk Taylor 2023-10-13 12:37:11 -07:00
parent db08110e56
commit ee78f4fbdf
No known key found for this signature in database
2 changed files with 26 additions and 2 deletions

@ -119,7 +119,9 @@ Location selection overlay
--------------------------
When choosing the type of guildhall or temple to dedicate, you can search for
the relevant profession, religion, or deity by name.
the relevant profession, religion, or deity by name. For temples, you can also
search for the "spheres" associated with the deity or religion, such as
"wealth" or "lies".
World overlay
-------------

@ -16,16 +16,38 @@ LocationSelectorOverlay.ATTRS{
frame={w=26, h=1},
}
local function add_spheres(hf, spheres)
if not hf then return end
for _, sphere in ipairs(hf.info.spheres.spheres) do
spheres[sphere] = true
end
end
local function stringify_spheres(spheres)
local strs = {}
for sphere in pairs(spheres) do
table.insert(strs, df.sphere_type[sphere])
end
return table.concat(strs, ' ')
end
local function get_religion_string(religion_id, religion_type)
if religion_id == -1 then return end
local entity
local spheres = {}
if religion_type == 0 then
entity = df.historical_figure.find(religion_id)
add_spheres(entity, spheres)
elseif religion_type == 1 then
entity = df.historical_entity.find(religion_id)
if entity then
for _, deity in ipairs(entity.relations.deities) do
add_spheres(df.historical_figure.find(deity), spheres)
end
end
end
if not entity then return end
return dfhack.TranslateName(entity.name, true)
return ('%s %s'):format(dfhack.TranslateName(entity.name, true), stringify_spheres(spheres))
end
local function get_profession_string(profession)