Latest Posts

Topic: Lua: plr:get_workers

kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2548
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2021-03-09, 10:59

I want to write an Addon as win_condition which archives the goal of the Tempo training tournament. In short this win condition should archive Who creates the first hero wins the game. Or maybe Who creates the first x heroes wins the game.

The problem is: I didn't found an easy way to get all workers/soldiers of a player. There is a function plr:get_workers() but this gives me only the number of workers, not instances of workers/soldiers. BTW: Looks like this function is not used anywhere.

Do i overlook something?

Can we have a function similar to plr:get_buildings() which returns a table of soldier objects? Then one can check the levels of each soldier.

Edited: 2021-03-09, 11:00

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2054
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-03-09, 11:45

Look at how it is done here: https://github.com/widelands/widelands/blob/master/data/campaigns/fri03.wmf/scripting/mission_thread.lua#L203-L217

+1 for adding a function to return all instances, open an issue for this please


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2548
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2021-03-09, 12:19

See: https://github.com/widelands/widelands/issues/4754


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2548
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2021-03-10, 09:23

I have trouble to find out the max levels of soldiers. From my understanding Soldier description should give me for get_max_health_level the maximum health level a soldier can get. But trying to get it it results in nil for both empire and barbarians.

max_defense_level gives me 0 for both tribes, which seems also not correct.

The values for max_attack_level and max_defense_level seems to be correct. This gives me for empire 4 (attack) and 2 (evade), for barbarians 5 (attack) and 2 (evade).

Is this a bug?


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2054
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-03-10, 12:34

The property is called max_health_level – typo in the documentation. There are more, I'll make a branch to clean this up.

Why is max_defense_level for bar and emp incorrect? They can't train defence so they always have level 0, this is correct.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2736
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2021-03-10, 13:24

If we go cleanup the documentation there are other issues in there as well. Shall we track them in the discussion of the branch or shall we open an issue to track them first.
I wanted to make a branch as well top clean the error(s) I found and will find


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2054
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-03-10, 13:40

I have already added the few I found to https://github.com/widelands/widelands/pull/4758/files#diff-151a692b2894cd9e863f4715863ba42785a85c7e4272474fc2f842a9faef6a44
And in the branch to fix #4759 I have found and fixed two outdated references to map objects' attributes attribute.

Let's open an issue to track everything else


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2548
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2021-03-10, 15:39

Nordfriese wrote:

The property is called max_health_level – typo in the documentation. There are more, I'll make a branch to clean this up.

Thanks a lot!

Why is max_defense_level for bar and emp incorrect? They can't train defence so they always have level 0, this is correct.

Yes, my fault. Was in hurry this morning.


Top Quote