How to implement electricity usage as a requirement for function

Started by jpwrunyan, April 28, 2014, 04:15:30 PM

Previous topic - Next topic

jpwrunyan

Hello all,

I am just dabbling with some simple modifications to the base game and already have a question. The first simple thing I wanted to do was make both the research bench and the orbital transmitter require electricity. That was easy. The problem is that even without electricity these two components appear to function as normal. If the research bench loses power, the character continues to blissfully progress onwards.

I suspect that this is hard-coded behavior, am I right? If not, could someone kindly tell me if I need to do something more to make objects that *consume* electricity actually *require* it in order to function?

FYI Here is the code I added to the components in question (the rest of their definition xml is unchanged):

<comps>
  <li>
    <compClass>CompPowerTrader</compClass>
    <startElectricalFires>true</startElectricalFires>
    <basePowerConsumption>100</basePowerConsumption>
  </li>
</comps>


PS startElectricalFires determines whether getting hit with rain outside causes the unit to short out, right?

Architect

You're right about the electrical fires. As for the research bench, i'm pretty confident that it is hard coded behavior. However, it should be perfectly possible to throw together a quick assembly so that it requires power, though i can at least look into it if you want?
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


Cala13er

Quote from: Architect on April 28, 2014, 04:21:44 PM
You're right about the electrical fires. As for the research bench, i'm pretty confident that it is hard coded behavior. However, it should be perfectly possible to throw together a quick assembly so that it requires power, though i can at least look into it if you want?

Don't worry, it's possible. Very easy mind that. :) Been working on research benches as part of an upcoming Full conversion mod I have planned after v2.0.0

jpwrunyan

Thanks guys. Right now I mostly want to make easy modifications that are supported by the .xml. I'm assuming that in the future any component that has electrical usage will by default require it in order to function or else have an .xml tag that specifies how the component should work when powered/not powered. I'm also assuming (and looking forward to)  eventually having dynamic electrical usage in addition to static. So if you had, for example, an electric fence, it would drain your power more when something steps into it (since it's basically just an exposed power conduit). Anyway, I was just thinking of fun stuff I could do with electricity but it will have to wait. I have more questions but will post them in a separate thread when the time comes (ie: when I finish the component and it inevitably doesn't work).

WorldOfIllusion

It seems that the WorkGiver_Researcher just checks if there is a research table, and the research table itself simply needs to exist (powered or not) for research to be done.
To change this, you'd probably need to add some new AI + modify Building_ResearchBench class to check if its powered.
Artistically challenged modder seeking artistically talented texturer's help. Please, please, PM me :)

jpwrunyan

Thanks again. Personally that is well beyond what I want to tackle at the moment.