Introduction:
I've read tons of source code to learn from others, but every energy mod had something in common: A lua script, running for every tick and every unit for circumventing limitations of entity types (for example a diesel-generator with a lua script transforming fuel into steam).
I've once tried to create a solarthermic plant (a solar powered boiler). Only way I've found to implement it was a storage tank and a lua script filling with steam out of nowhere by a filling rate depending on game_darkness.
It works but after building hundreds of it, the lua script made the game running at half speed - that's why I've never published the mod.
For example, let's take a look at the energy sources of (vanilla) solar panel, steam engine, electric and stone furnace:
steam-engine:
Code: Select all
type = "generator",
    name = "steam-engine",
    energy_source =
    {
      type = "electric",
      usage_priority = "secondary-output"
    }
solar panel:
Code: Select all
type = "solar-panel",
name = "solar-panel",
energy_source =
    {
      type = "electric",
      usage_priority = "solar"
    },
production = "60kW"
furnaces:
Code: Select all
    type = "furnace",
    name = "stone-furnace",
    energy_source =
    {
      type = "burner",
      fuel_category = "chemical",
    }
Code: Select all
    type = "furnace",
    name = "electric-furnace"
    energy_source =
    {
      type = "electric",
      usage_priority = "secondary-input",
      emissions = 0.005
    }
If hot liquid, wind and solar power would be implemented as an energy_source additional to existing (electric, burner,...) above examples would be easily defined like this:
steam-engine:
Code: Select all
type = "generator",
    name = "steam-engine",
    energy_input_source =
    {
      type = "hot liquid"
    }
    energy_output_source =
    {
      type = "electric",
      usage_priority = "secondary-output"
    }
Code: Select all
type = "generator", //(!)
name = "solar-panel",
    energy_input_source =
    {
      type = "solar"
    }
energy_output_source =
    {
      type = "electric",
      usage_priority = "solar"
    },
production = "60kW"
Code: Select all
    type = "generator",
    name = "diesel-generator",
    energy_input_source =
    {
      type = "burner",
      fuel_category = "chemical",
    }
    energy_output_source =
    {
      type = "electric",
      usage_priority = "secondary-output"
    }
Code: Select all
    type = "boiler,
    name = "solar-boiler,
    energy_input_source =
    {
      type = "solar",
    }
    //Edit: Removed energy_output_source for boiler, because type=boiler already defines what it does
Code: Select all
    type = "car",
    name = "solar-car"
    energy_input_source =
    {
      type = "solar",
    }
(English is not my native language. If there are disturbing mistakes or parts even not understandable please notify me)






 For the other people out there, let's expand on what I meant.
  For the other people out there, let's expand on what I meant.