Latest Posts

Topic: How can I iterate over all conquered player buildings, his tribe not know?

Topic Opener
Joined: 2017-02-08, 20:06
Posts: 329
Tribe Member
Location: Eisenach, Germany
Posted at: 2021-07-30, 17:07

How can I iterate (in Lua) over all buildings from a player, his tribe not know.

Problem is, this code:

    for i, tbuilding in ipairs(player.tribe.buildings) do
       for j, building in ipairs(player:get_buildings( do

don't work, if I search buildings that a player conquered in the game but are not part of his tribe.

I wouldn't iterate over all immovable object on map, because this takes a long time.

My widelands addons:

Top Quote
Joined: 2014-12-11, 22:16
Posts: 2672
One Elder of Players
Location: Bavaria
Posted at: 2021-07-30, 21:59

you may have a look at data/scripting/win_conditions/win_condition_functions.lua I used p.allowed_buildings there for this purpose.

Top Quote
Joined: 2013-02-18, 19:48
Posts: 2456
OS: Archlinux
Version: current master
One Elder of Players
Location: Germany
Posted at: 2021-07-30, 22:52

Since only military buildings get conquered you may create a list of all military buildings of all players. And then compare the buildings owner.

For gathering military buildings names i've done similar in my auto_soldiers addon:

Fight simulator for Widelands:

Top Quote