Topic: Allow buildings to specify the icon used for “Purpose” in the Help

Kontorotsui
Avatar
Topic Opener
Joined: 2021-05-20, 15:35 UTC+2.0
Posts: 46
Ranking
Pry about Widelands
Posted at: 2026-08-25, 20:39 UTC+2.0

While working on a custom tribe, I noticed that the icon displayed next to the “Purpose” section in the building help text is always selected automatically in building_help.lua.

For production sites, the code tries output_ware_types[1], then output_worker_types[1], and then has several other fallbacks.

This works reasonably well in general, but it means that the building author cannot explicitly choose which object should represent the purpose of the building.

For example, I have a building that produces meat, fish and wool, and also recruits a donkey. For this particular building the donkey is the important new feature, so I would like the Purpose icon to be the donkey. The current automatic selection instead uses one of the produced wares because they have priority in the choosing of the icon.

I was thinking that an optional field such as purpose_icon in the building helptexts in units.lua could solve this:

helptexts = { purpose = pgettext(...), purpose_icon = "carrier_donkey" }

If purpose_icon is specified, the Help would use it; otherwise the current automatic selection would remain unchanged.

I already checked the code and I can prepare the corresponding code change and submit it if this sounds like a useful addition. What do you think?


1
Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16 UTC+1.0
Posts: 2934
OS: Windows
Version: always the latest
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2026-08-27, 20:59 UTC+2.0

+1 from my side as the icons in some of our legacy tribes, have similar problems. e.g. the frisian hunter


2
Top Quote
Kontorotsui
Avatar
Topic Opener
Joined: 2021-05-20, 15:35 UTC+2.0
Posts: 46
Ranking
Pry about Widelands
Posted at: 2026-09-03, 18:20 UTC+2.0

Thanks, give me a few days and I will propose the code change, it is pretty small and straightforward.


Top Quote
Kontorotsui
Avatar
Topic Opener
Joined: 2021-05-20, 15:35 UTC+2.0
Posts: 46
Ranking
Pry about Widelands
Posted at: 2026-09-17, 00:09 UTC+2.0

Ok, I made the change and tested it. It works perfectly, and if you mistype the purpose_icon you want, it simply shows no icon in the Purpose section of the encyclopedia, so you can tell that something is wrong.

I don't know how to submit the change. It is just a few lines in building_help.lua, so here is the diff:

<    
< if helptexts["purpose_icon"] ~= nil then
<    local purpose_icon = helptexts["purpose_icon"]
< 
<    if tribe:has_ware(purpose_icon) then
<       representative_resource = wl.Game():get_ware_description(purpose_icon)
<    elseif tribe:has_worker(purpose_icon) then
<       representative_resource = wl.Game():get_worker_description(purpose_icon)
<    end
< elseif (building_description.type_name == "productionsite") then
---
>    if (building_description.type_name == "productionsite") then

You only need to add the following to the appropriate building's helptexts section in units.lua:

purpose_icon = "fur"

This makes the encyclopedia show fur as the icon.

It works with both wares and workers.

If this approach is acceptable, I can prepare the proper code change. Otherwise, please let me know how you would prefer me to submit it officially.


Top Quote