Latest Posts

Topic: soldiers (heroes) on a warship

kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2550
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2024-10-10, 17:35

I want to write a win condition which counts the number of heroes on a warship. But it seems there is no way to achieve this.

For a ship i can use e.g. ship:get_workers("empire_soldier") to get the amount of soldiers on this ship. But i can't find a way to check the levels of the soldiers.

If i use ship:get_workers("") i get a table of workers, but it seems this table is empty (at least for a warship) and this way it is also not possible to check the levels of soldiers.

Do i overlook something again?


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2055
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2024-10-11, 11:00

This works for me:

for i,soldier in ipairs(ship:get_workers("")) do print(soldier.attack_level) end

Could you provide your code?


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2550
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2024-10-11, 11:41

Oh yeah, sorry, my fault. I just forgot to rename a variable in every place. face-sad.png


Top Quote