• 📚 A new project from the admin: Check out PictureBooks.io, an AI storyteller that lets you build custom picture books for kids in seconds. Let me know what you think here!

Require Power to build building?

jefmart1

Prince
Joined
Aug 16, 2005
Messages
463
Is there some way to require a city to have power before it can build a building? I know that seems nitpicky, but it is realistic. I'm thinking about it for a post-apocalyptic mod where there is no power grid, but there is possibly modern technology like factories that are intact, but to use them or build new ones you need power.

I suppose they could have no effect without power and power would add the effect. But I was also thinking of having resources only produced by buildings, like ammunition, that would require power to work.
 
There is a subtle distinction in what you are asking: do you want to require power in order to build the building, or do you want power in order for it to work?

The former is probably easy; the latter is trickier. Basically, what you're trying to do is treat power like a resource. I suppose you can check in Python to see if a city has power and then enable the building if it does, but off the top of my head I would not know how to override the effect of a factory if it suddenly lost its power. That's actually something I'm looking into for the Quantitative Resources proposal, and like I said it's tricky.
 
Factories already need power to give part of their bonus, so if that was what you wanted then that would be easy.
 
Factories already need power to give part of their bonus, so if that was what you wanted then that would be easy.

That part is easy. If you want to make it so that the factory stops putting out resources (like ammunition) when you lose power, then you will need additional code, I believe.
 
How do I require the power to build the building in the XML, I cannot find anything that relates.

I'm new to XML modding so please be specific...
 
If you are new to XML coding and know no Python, you'll probably have to forget it. :( I am almost certain there is no tag in XML to require power, and the solution thus lies at least in Python.
 
OK,

Then I'm begging anyone who knows Python to create the code for me that does this. PLEASE????
 
Back
Top Bottom