Selecting 'available' factories

Everything about mods can be found here.

Moderator: Morax

Selecting 'available' factories

Postby crispweed » 18 Jan 2019, 11:56

I have a selection helper mod, with helpers for things like selecting the idle units in a given category.

I'd like to change the definition of idle used for factories in this mod slightly, however, to include factories that are assisting other factories, but have no build queue of their own.

(I guess, instead of 'idle', we could then say 'available'.)

I can't see how to check whether or not a factory has a build queue, however.
Anyone have any ideas about how to do this (or whether this is possible from a UI mod)?

(I can get the *command* queue, with unit:GetCommandQueue(), and use this to modify the definition of idle/available for mobile units, but can't see any corresponding way to get information about the *build* queue..)
crispweed
Crusader
 
Posts: 33
Joined: 02 Jan 2017, 17:32
Has liked: 2 times
Been liked: 3 times
FAF User Name: crispweed

Re: Selecting 'available' factories

Postby nine2 » 18 Jan 2019, 21:47

You should be able to figure that out by looking through the code that renders the build queue.

Easier, You could just test if it is assisting or not. In code it is called Guarding I think
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Selecting 'available' factories

Postby crispweed » 18 Jan 2019, 22:56

Anihilnine wrote:Easier, You could just test if it is assisting or not. In code it is called Guarding I think


That doesn't quite do it, because sometimes the assisting factories *will* have some build queue of their own (and should not then be considered 'available').

Anihilnine wrote:You should be able to figure that out by looking through the code that renders the build queue.


I had a look at some stuff like this, in construction.lua, but, in order for the build queue to be rendered, the factory has to be selected, and I have a feeling that other code related to manipulating the build queue may also depend on some selection hooks triggering.

I'll have another look this, though, and see if I can figure out what's going on..
crispweed
Crusader
 
Posts: 33
Joined: 02 Jan 2017, 17:32
Has liked: 2 times
Been liked: 3 times
FAF User Name: crispweed

Re: Selecting 'available' factories

Postby nine2 » 18 Jan 2019, 23:22

Yes, you need to select the unit. In uiparty I remember current selection, select each fac, get build queue, to work out things like what I are talking about. At the end I restore the original selection. User doesn't even know it's happened. Sounds expensive but I do it every second and it's fine. If you are doing it in response to a shortcut it will be fine.

However, much easier solution is just test if it's (idle and not guarding)
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest