This may have already been answered, but I'm wondering if there is a variable that a factory could look up to see which commander the player selected. I want to use this for a decoy commander mod (TA, anyone?). Thanks in advance.
short answer: no. Only in a very limited and roundabout way - different commanders could build different everything so that that one unit would know what to build. This is awkward and limited to 16 settings (commanders) as far as we know.
So there isn't even a "unit_exists" function or something? That sucks. Perhaps offer all the commanders and let the player select the one they have. Seems clunky, but it would be better than nothing...
You could do more with scripting. Maybe set up the factory it so can build all commanders and then use script to set the right one into the build bar. You would need to decide what to do with multiple commander team games though.
Hmm... we really ought to make one on pawiki. And thinking about it, this is a little tricky because you're straddling the client/server boundery. You have to change the factory properties (look at the unit/balance mods for examples), and you have to run code on every player's client to change build settings. This will mean shadowing (same ideas as the unit mods - psuedo-replacing a file at runtime) at least one file. I'd take this in small bites. Figure out how to make a simple change to a unit. Cost, damage, etc - some simple number. Play with unittypes and buildable types for existing units. Figure out how to add a single static new unit (e.g. pick one commander to make buildable) Take a look at some mods that do server mod UI shadows - mine include Puppetmaster, Commander Regeneration, and Mod Help Player Guide (server edition) Then we'll talk about putting it all together.