Bay 12 Games Forum

Dwarf Fortress => DF Modding => Utilities and 3rd Party Applications => Topic started by: Saiko Kila on October 30, 2018, 03:57:36 pm

Title: [Lua script] List gods, temples and worshippers list-gods.lua
Post by: Saiko Kila on October 30, 2018, 03:57:36 pm
DFhack Lua script, to be put in hack/scripts/list-gods.lua
It's for v0.44.12.

Spoiler (click to show/hide)

This is a script to show all gods available, their number of worshippers (divided into three categories: citizens, long-term residents and short-term visitors), as well as status of the best temple for each god, plus assigned zones. I had to make it when my fortress reached about 100 gods and started to have problems with temple management. It allowed me to discover popular gods with no temples, gods who lost popularity, or find zones/rooms assigned to temples and forgotten, which is not that easy with DF's interface.

The script otputs to DFhack's console, but the mode of action depends on the cursor or highlight in the main DF window.

Options:
-help will show a reminder of main options ("list-gods -help")
-all will show gods worshipped by visitors only, in addition to citizens+LTRs
-domain will show domains (spheres) of the gods in the main list
-noroom will prevent showing rooms (but not zones) assigned to locations


Color coding for temples are:
light green - all visitors welcome
white - citizens and long-term residents only
yellow - citizens only
blue - there is no zone/room assigned to the temple (so it has no physical location)
dark grey - the temple doesn't exist (used for gods with no temples)


There are three modes:
1. default mode - gods available for creating temples are shown, ordered according to the number of worshippers (most popular on top), and colored depending on status/inclusivity of their best temple. Additionally all universal temples are listed (dedicated to no particular deity), as well as orphaned temples (dedicated to deity which has no longer worshippers).

Without additional option only gods avaialble are listed, i.e. ones worshipped by your civ or citizens and long-term residents on map. But with option "-all" also gods worshipped by visitors are listed. The game doesn't count visitors when displaying gods available and number of worshippers, that's why this is optional here. There is also option "-domain" (or "-domains") which will display domains (spheres) associated with that god.

[EXAMPLE]
Spoiler (click to show/hide)

2. zone/temple mode - when either the cursor is on a zone in main window, or the location is highlighted in the list of locations. Shows name of the zone (or zones, if overlapping) under the cursor, color-coded name of the temple, spheres associated with the god, number of worshippers of each category, and zones and rooms.

There is additional option, "-noroom", which prevents counting the rooms, only zones are shown. This is mostly useful with taverns actually, unless you assign rooms to the temples too.

[EXAMPLE]
Spoiler (click to show/hide)

3. unit mode - when the unit is selected in any way (even in list of deads). Shows citizenship status of the unit, all gods worshipped by it (color-coded according to the best temple), associated spheres, need for worship (not all worshippers need to actully worship the god), as well a focus level associated with worshipping the particular god.

[EXAMPLE]
Spoiler (click to show/hide)

EDIT:
Title: Re: [Lua script] List gods, temples and worshippers list-gods.lua
Post by: Pvt. Pirate on November 05, 2018, 12:53:08 pm
can you add the domains to the list?
Title: Re: [Lua script] List gods, temples and worshippers list-gods.lua
Post by: Saiko Kila on November 05, 2018, 02:58:47 pm
can you add the domains to the list?

Sure, added this option. Use either "-domain" option or change LIST_DOMAINS to true in the CONFIGURATION part near beginning. However, for neat output this requires console wider than the standard 80 characters in Vista/Win7 (120 characters in never Windows versions should be enough). Console width (including default) can be changed in Properties of the window if need be.
Title: Re: [Lua script] List gods, temples and worshippers list-gods.lua
Post by: Pvt. Pirate on November 05, 2018, 03:07:07 pm
cool :)
Title: Re: [Lua script] List gods, temples and worshippers list-gods.lua
Post by: seyedaed on November 06, 2018, 12:46:35 am
Hey this is pretty cool! Nice work!
Title: Re: [Lua script] List gods, temples and worshippers list-gods.lua
Post by: Saiko Kila on November 07, 2018, 03:48:44 am
Thanks.

I fixed an error with domains of gods worshipped by civ but by no citizens (it was present only in early fortresses in default mode). Also output is a bit neater now, especially if there are 100 or more gods.
Title: Re: [Lua script] List gods, temples and worshippers list-gods.lua
Post by: vityav on February 06, 2022, 11:49:08 pm
This is a wonderful script; makes managing temples so much easier when you don't remember what 10 gods you've already made temples to. Just in case anybody comes here from 0.47 versions of dfhack, some changes to get it going (I don't know that it's at full functionality, but this will run and correctly highlight which deities already have temples):

Code: [Select]
201: for k,v in ipairs(df.global.world.entities.all[civ_k].unknown1b.deities) do --add civ gods, if missing becomes
Code: [Select]
201: for k,v in ipairs(df.global.world.entities.all[civ_k].relations.deities) do --add civ gods, if missing
Code: [Select]
236:  tlist[k]={v.id,v.deity,v.name,acc,false}becomes
Code: [Select]
236:  tlist[k]={v.id,v.deity_data.Religion,v.name,acc,false}