Page 1 of 1

Trying to make a Solar Water Heater, code help please?

Posted: Tue Apr 26, 2016 6:54 pm
by Taehl
Hi, all. I'm still getting used to modding Factorio, and my latest little endeavour has me stumped. I'm trying to make an early-game version of the Solar Panel which doesn't make electricity directly, rather, during the day it acts as a boiler for powering steam engines. My naive guess was that I would need to base it on the "boiler" type, and I'm getting all sorts of odd behaviour. Does anyone know what and how I'm messing up? I'd appreciate the insight.

Code: Select all

data:extend( { {
    type = "boiler",
    name = "solar-boiler",
    icon =  "__Tmod__/graphics/icons/solar-boiler.png",
    flags = {"placeable-neutral", "player-creation"},
    minable = {hardness = 0.2, mining_time = 0.5, result = "solar-boiler"},
    corpse = "big-remnants",
    collision_box = {{-1.4, -1.4}, {1.4, 1.4}},
    selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
    vehicle_impact_sound =  { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
    picture =          -- seems to do nothing? graphics are defined in "structure" instead?
    {
      filename = "__Tmod__/graphics/entity/solar-boiler.png",
      priority = "high",
      width = 104,
      height = 96
    },
    fluid_box =          -- later I think I'll make only have two sides with pipes, but right now testing with all four
    {                       -- wouldn't it be fun if players were forced to contend with "L"-shaped plumbing? :D
      base_area = 1,
      pipe_covers = pipecoverspictures(),
      pipe_connections = { {position={0, 2}}, {position = {0, -2}}, {position={2, 0}}, {position = {-2, 0}} }, 
    },
    energy_consumption = "0kW",         -- doesn't consume energy; I was planning on having them add heat using control.lua
    max_health = 35,
    -- these are the pipe pictures - boiler is a pipe as well
    pictures = pipepictures(),
--    fast_replaceable_group = "pipe",
    burner =
    {
      effectivity = 1,
      fuel_inventory_size = 0,         -- you don't put fuel in it
      emissions = 0,                      -- clean energy
      smoke =
      {
        --[[{                   -- don't emit smoke
          name = "smoke",
          position = {0.0, -0.8},
          frequency = 0,
          starting_vertical_speed = 0.0,
          starting_frame_deviation = 60
        }--]]
      }
    },
   structure =         -- this seems... less than efficient
    {
      left =
      {
        filename = "__Tmod__/graphics/entity/solar-boiler.png",
        priority = "extra-high",
        width = 104, height = 96, shift = {0, 0},
      },
      down =
      {
        filename = "__Tmod__/graphics/entity/solar-boiler.png",
        priority = "extra-high",
        width = 104, height = 96, shift = {0, 0},
      },
      left_down =
      {
        filename = "__Tmod__/graphics/entity/solar-boiler.png",
        priority = "extra-high",
        width = 104, height = 96, shift = {0, 0},
      },
      right_down =
      {
        filename = "__Tmod__/graphics/entity/solar-boiler.png",
        priority = "extra-high",
        width = 104, height = 96, shift = {0, 0},
      },
      left_up =
      {
        filename = "__Tmod__/graphics/entity/solar-boiler.png",
        priority = "extra-high",
        width = 104, height = 96, shift = {0, 0},
      },
      right_up =
      {
        filename = "__Tmod__/graphics/entity/solar-boiler.png",
        priority = "extra-high",
        width = 46,
        width = 104, height = 96, shift = {0, 0},
      },
      t_down =
      {
        filename = "__Tmod__/graphics/entity/solar-boiler.png",
        priority = "extra-high",
        width = 44,
        width = 104, height = 96, shift = {0, 0},
      },
      t_up =
      {
        filename = "__Tmod__/graphics/entity/solar-boiler.png",
        priority = "extra-high",
        width = 46,
        width = 104, height = 96, shift = {0, 0},
      }
    },
    fire =          -- shouldn't show fire
    { --[[
      left = boilerfires.down,
      down = boilerfires.left,
      left_down = boilerfires.right,
      right_down = boilerfires.left,
      left_up = boilerfires.down,
      right_up = boilerfires.down,
      t_up = boilerfires.down
--]]
    },
    burning_cooldown = 20,		--]]
} } )

data:extend( { 
   {
    type = "item",
    name = "solar-boiler",
    icon = "__base__/graphics/icons/solar-panel.png",
    flags = {"goes-to-quickbar"},
    subgroup = "energy",
    order = "b[steam-power]-a[solar-boiler]",
    place_result = "solar-boiler",
    stack_size = 50
  },
  {
    type = "recipe",
    name = "solar-boiler",
    ingredients =
    {
      {"pipe", 4},
      {"iron-plate", 1},
      {"copper-plate", 4},
    },
    result = "solar-boiler"
  },
 } )
And since they don't have fuel, Factorio gives them the blinking "no fuel" icon, which is less than ideal too.

Re: Trying to make a Solar Water Heater, code help please?

Posted: Tue Apr 26, 2016 7:02 pm
by Lutra
use:

energy_source =
{
type = "electric",
usage_priority = "solar"
}

then maybe

energy_consumption = "1W"


that would make the boiler's heating power vary directly with the in game time, just like solar panels. not entirely sure if it will work, but try anyway(i stole it from the base code for solar panels 8-) )

Re: Trying to make a Solar Water Heater, code help please?

Posted: Tue Apr 26, 2016 7:03 pm
by Supercheese
You can check out this mod and see how it handles things: viewtopic.php?f=93&t=13381