Fueled Heaters [Help Required]

Started by Liquidhalo231, February 10, 2018, 10:01:55 AM

Previous topic - Next topic

Liquidhalo231

Hi everyone! With the exciting addition of Chemfuel Generators in B18 I thought it may be nice to have a type of heater that can work during solar flares or for low power buildings that isn't just "Light an open fire in your wooden shack"

Today I introduce something I made from the generator's sprite itself, the chemfuel and woodburning heaters:





Now, I don't care if you guys want to take these sprites, the idea, whatever, go nuts.

I just want some help making this possible, can someone help me please?

Here are my wants for these heaters:


  • They work without power and during solar flares.
  • They are the same as or more efficient than the generators that they are inspired by.
  • They can be researched before Electricity and require 100-200 Research
  • The sprites toggle states when they are on/off if the game's engine allows this.
  • They glow a bit and let off a bit of light, not as much as a fire, but about as much as a heater
  • They can be toggled on and off when not needed and retain their fuel without burning it when they are off, like the generators.
  • Target temperature can be adjusted but it affects efficiency as it burns more/less fuel depending on what the temperature is in the room.

If anyone can help me with this please get in contact, I know basic modding for this game but nothing this complex, always happy to learn though.

jamaicancastle

So, good news/bad news. From what I can see you have a couple of options, depending on how complex of a mod you want to make.

The bad news is that making your generator work with the temperature control widget is going to take some C# coding. Nothing tremendously complex, but it would mean having to learn the basics of the C# workflow. If you want to pursue that option, there's a good tutorial on starting up with C# modding in the pinned topics. Having the sprite switch between active and passive states also needs C#.

Just with XML, you could make a campfire-like heat pusher, which would produce heat at a steady rate until it meets a specific target temperature. Notably it wouldn't be able to throttle itself when near the target temperature. However, it would have most of the other properties you want: it would be fuel-burning, flickable, and it would work without power.

Make a copy of the fueled generator (either of them) and note the "comps" section. Comps are components that make a thing act in a certain way.
<comps>
  <li Class="CompProperties_Power">
    <compClass>CompPowerPlant</compClass>
    <basePowerConsumption>-1000</basePowerConsumption>
    <transmitsPower>true</transmitsPower>
  </li>
  <li Class="CompProperties_Flickable" />
  <li Class="CompProperties_Refuelable">
    <fuelConsumptionRate>4.0</fuelConsumptionRate>
    <fuelCapacity>25.0</fuelCapacity>
    <fuelFilter>
      <thingDefs>
        <li>Chemfuel</li>
      </thingDefs>
    </fuelFilter>
  </li>
  <li Class="CompProperties_Glower">
    <glowRadius>6</glowRadius>
    <glowColor>(80,112,180,0)</glowColor>
  </li>
  <li Class="CompProperties_HeatPusher">
    <compClass>CompHeatPusherPowered</compClass>
    <heatPerSecond>3</heatPerSecond>
  </li>
  <li Class="CompProperties_Breakdownable"/>
</comps>


The first is the power comp, which you'll want to delete. Flickable controls whether it can be turned on or off. Refuelable controls how it is fueled; fuelCapacity is how many units of fuel it can store, and fuelConsumptionRate is how many units it burns per day of use. Glower is whether it will produce a glow while active. HeatPusher is what will actually generate heat. Breakdownable will allow the building to break down and require repairs; you can keep that or remove it as you wish.

You'll want to adjust two parts of the HeatPusher comp. One is to make it stronger by increasing the heatPerSecond field. The other is to create a heatPushMaxTemperature field, which will keep it from overheating your colonists. (Note that the field name is case sensitive.) For reference, the campfire generates 21 heat/second to a maximum temperature of 28 Celsius.

(The chemfuel generator also has an Explosive comp which, as you might expect, is what makes it blow up when damaged; I didn't copy that above because it's quite a bit longer. It's up to you whether you want to remove it, keep it, or adjust it.)

The heater's efficiency will be determined by how much fuel it burns per day, compared to what you'd get if you put it in a generator and hooked up electric heaters to that. You'll probably have to experiment with the fuel rate until you find one that feels right.

As for research, at the very end of most building defs you'll find the ResearchPrerequisites field. You can easily set this to any of the vanilla ResearchProjectDefs, or you can make your own. You can also remove it if you want to allow it to be built without research.

Liquidhalo231

Sorry for the late reply, I wanted to say thank you for all the help, I only managed to get the funtionallity working, not so much the changing graphics or adjustable temperature but I did it, thank you so much!