Then to answer the main question. Provided this is a actual problem under the current game meta, and that if it were not just for my own personal use atm, as well as a way to learn scripting.
That's cool, working out how to do something like this is fine just to learn, and I definitely want to encourage more scripters. Plus, it might sort of fit into some nascent ideas I've had for giving some buildings a tag like "megastructure" and having some way to limit the number of them you can build per planet—you can build your Gun on Ice Planet Zero, but that planet then can't have other things and/or those other things are more expensive.
Plus, I'd insist this sort of thing were balanced by, for example, having a massive planetary shield penalty and/or only being able to fire if the planet is on Defence focus.
However, until/unless we introduce such a mechanic this sort of thing is, as per Sloth's point, not something we'd want that you feel the need to build everywhere.
Then it seems to me there is a ton of non military buildings currently, i don't want to do the micro that i do now.
We are trying to both reduce the amount of these things and not introduce new ones, redoing the mechanics in such a way that anything that is currently micromanagement is reduced.
We have to micro military buildings like elevators, docks, lighthouses,
Elevators shouldn't be needed in that many places if at all, even on Low Planets/Low Starlanes they should be a rare build not a constant build, they certainly are for me so I haven't considered them a problem. Drydocks and shipyards are meant to be built rarely and at strategic locations—that's not currently the case but the main reason it hasn't been fixed is it requires an AI rewrite and the AI team have more important stuff to work on currently.
Lighthouses are a problem I agree, I personally rarely build them (starlane drive is my main use for them), and I'm considering fixing them in some way, possibly replacing their current bonus with something that complements Interstellar Logistics, increasing the range of that bonus would work and mean you choose where to put them.
the industry building,
Specifically and definitely not, that's a one-per-empire building and works for all supply-connected worlds.
But click spamming crappy little troop ships is more 'cost effective' then having a capital sized dedicated troop ship drop troop pods,
Last time I checked the maths, the reverse is normally true, larger ships tend to be cheaper on overall slots/point, there are exceptions (the Flux hull is too cheap but far too fragile) but generally bigger=cheaper, that's deliberate. In addition, each ship in your fleet increases upkeep for all other ships being built, so spamming lots of little ships increases the costs of everything
With the exception of the Flux hull, can you give examples of what you think is more cost effective for troop ships, I may need to adjust the numbers (again) if you feel that's currently the case, personally I don't think it is.
In effect this is a anti micro mechanism against small cheap troop ships spammed all over the place.
It also works against the idea of fleet repair en mass in a enemy system which breaks expectations.
Fleets shouldn't be able to repair in enemy systems, all of the repair techs are gated to require no combat and virtually all of the ship repair effects from elsewhere have been toned down or eliminated now.
There are two primary ways to categorize the removal of micro logically.
1) Automate it.
This falls into the realm of ai or programming this tends to remove micro entirely.
(One exception is 'focus' which is a excellently implemented example of both micro and macro balanced. Conversely however bad examples are, the industry building it is build micro, that should be auto built by industry focus, While mines are instant built every-were macro via one click on a tech).
I agree with this except the industry building, again it isn't necessary to build more than one.
A better example would be the Gas Giant Generator and that's something we've discussed changing a few times.
Make choosing to build or not build something, a choice that isn't to be taken lightly. e.g. If i die every game i just spam a thing, then ill learn not to.
(The cost vs value needs to be considered. The implementation can be creative, typically you make it better at a higher cost, but this can be in any form you can think up).
Alternate ways to think of cost or restriction:
Say you have to already build something to get something else. This is how tech works, but it could be given by some other building that you already have to micro build, maybe one you really don't want too, in order to make it feel less tedious, like a (lighthouse or scanner) or (industry factory). There are other ways to make things have a cost. You could have to build a System military factory on just one planet, That might automatically provide a gun per planet this might have a high cost but be worth it only in certain places of high value.
Agree with this, definitely, having choices that push you to an either/or or have a strong disadvantage is a good thing, far too often people think of costs in pure production cost, but time and other resources effects can be costs. If having this gun reduced planet shields substantially that would be an interesting different cost and provide a choice, etc.