Currently Online

Latest Posts

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

Joined: 2017-02-08, 21:06
Posts: 298
Tribe Member
Location: Eisenach, Germany
Posted at: 2021-07-30, 18: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 project:

Top Quote
Joined: 2014-12-11, 23:16
Posts: 2073
One Elder of Players
Location: Bavaria
Posted at: 2021-07-30, 22: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, 20:48
Posts: 2120
One Elder of Players
Location: Germany
Posted at: 2021-07-30, 23: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:

Top Quote