Topic: get_workers() (wl.game.Player method) should get a table / array of workers like get_buildings
|
beng Topic Opener |
Posted at:
2025-12-07, 09:04 UTC+1.0
There are lua functions for the player called get_ships() and get_buildings() that return an array of ships or buildings for that player. However, there are no similar functions to return an array of workers for that player. The get_workers() function returns the number of workers. For scripting purposes it would be helpful if there was a way to get the workers of a particular player as an array so a script can iterate though them to check what they are doing or where they are. For example, in pseudo code:
Edited:
2025-12-07, 09:05 UTC+1.0
Top
Quote
|
|
kaputtnik |
Posted at:
2025-12-07, 10:19 UTC+1.0
In a game there are many, many, workers and the workers are created on demand (if the corresponding tools are available). For scouts such a function might be sufficient because one usually does not have much workers of type You can probably do something like this:
Top
Quote
|
tothxa
|
Posted at:
2025-12-07, 10:20 UTC+1.0
I think that's because you cannot do anything with individual workers (so there are no lua hooks, or even C++, for that either), and that's a core part of the game mechanics.
Top
Quote
|
hessenfarmer
|
Posted at:
2025-12-07, 13:12 UTC+1.0
that is exactly how it is done in Fri02 and Atl02 for example.
Top
Quote
|
|
beng Topic Opener |
Posted at:
2025-12-08, 03:23 UTC+1.0
Yes, I saw the code in Atl02 which is why I made this suggestion. It is clunky and inefficient and does not always work (i found this in gameplay where the script would not trigger) perhaps because the scout may be outside the range that is checked or if the game is speeded up it may have gone outside the check range in between the scripted sleep periods or whatever. It would be better if a script could simply get an array of all the player's scouts (or hunters etc) and then iterate through them to check and so some stuff.
Top
Quote
|


