Page 1 of 1

[Dominik][0.17.64] When pipe is built before furnace, furnace cannot output to pipe/fluid disappears

Posted: Sat Aug 10, 2019 8:11 am
by Bilka
Reporting this on behalf of Linver, maintainer of Krastorio, who wasn't sure if this is a bug with their mod or the base game. I think it it a base game bug.

Setup: Download latest version of Krastorio, krastorio graphics and aswil.
Reproducing:
1. Place pipe
2. Place "matter factory" so that it feeds the pipe (connection is bottom middle)
3. Insert "sand" into matter factory

Observe:
No fluid is produced, despite the recipe having a fluid product.

Making fluid get produced:
1. mine pipe
2. place pipe again
OR
1. Load save file in higher game version (0.17.64 -> 0.17.65 worked for me)

For completeness, here is the prototype for the machine

Code: Select all

{
    type = "furnace",
    name = "matter-factory",
    icon_size = 32,
    icon = krstr_entities_icon_path .. "matter_factory_icon.png",
    flags = {"placeable-neutral","placeable-player", "player-creation"},
    minable = {mining_time = 1, result = "matter-factory"},
    max_health = 3000,
    result_inventory_size = 1,
    source_inventory_size = 1,
    corpse = "huge-kf-remnants",
    dying_explosion = "big-matter-explosion",
    resistances =
    {
    {type = "physical",percent = 60},
    {type = "fire",percent = 70},
    {type = "impact",percent = 70}
    },
    fluid_boxes =
    {      
        {
            production_type = "input",
            pipe_covers = pipecoverspictures(),
            pipe_picture = krpipepictures(),
            base_area = 10,
            base_level = -1,
            pipe_connections = {{ type="input", position = {0, -4} }}
        },     
        {
            production_type = "output",
            pipe_covers = pipecoverspictures(),
            pipe_picture = krpipepictures(),
            base_area = 10,
            base_level = 1,
            pipe_connections = {{ type="output", position = {0, 4} }}
        },
        off_when_no_fluid_recipe = false
    },
    collision_box = {{-3.4, -3.4}, {3.4, 3.4}},
    selection_box = {{-3.5, -3.5}, {3.5, 3.5}},
    fast_replaceable_group = "assembling-machine",
    animation =
        {
        layers =
        {
        {
            filename = "__Krastorio-graphics__/graphics/entity/matter-factory/matter-factory.png",
            priority = "high",
            scale = scale,
            width = 268,
            height = 268,
            frame_count = 1,
            hr_version =
                {
                filename = "__Krastorio-graphics__/graphics/entity/matter-factory/hr-matter-factory.png",
                priority = "high",
                scale = scale,
                width = 536,
                height = 536,
                frame_count = 1,
                scale = 0.5,
                }
        },
        {
            filename = "__Krastorio-graphics__/graphics/entity/matter-factory/matter-factory-sh.png",
            priority = "high",
            scale = scale,
            width = 268,
            height = 268,
            frame_count = 1,
            draw_as_shadow = true,
            hr_version =
                {
                filename = "__Krastorio-graphics__/graphics/entity/matter-factory/hr-matter-factory-sh.png",
                priority = "high",
                scale = scale,
                width = 536,
                height = 536,
                frame_count = 1,
                draw_as_shadow = true,
                scale = 0.5,
                }
        }
        }
        },
    working_visualisations =
    {
      {
        animation =
        {
          filename = "__Krastorio-graphics__/graphics/entity/matter-factory/matter-factory-working.png",
          scale = scale,
          width = 268,
          height = 268,
          frame_count = 16,
          line_length = 4,
          animation_speed=0.6,
          hr_version =
            {
            filename = "__Krastorio-graphics__/graphics/entity/matter-factory/hr-matter-factory-working.png",
            scale = scale,
            width = 536,
            height = 536,
            frame_count = 16,
            line_length = 4,
            scale = 0.5,
            animation_speed=0.6,
            }
        },
        light =
        {
        intensity = 0.7,
        size = 20,
        shift = {2.0, 0.0},
        color = {r=0.1, g=0.5, b=1}
        }
      },
      },
        crafting_categories = {"matter-extraction"},
        vehicle_impact_sound =  { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
        working_sound =
        {
            sound =
        {
        {
            filename = "__Krastorio-graphics__/sound/matter-factory.ogg",
            volume = 1
        }
        },
        idle_sound = { filename = "__base__/sound/idle1.ogg", volume = 1 },
        apparent_volume = 1.5
        },
        crafting_speed = 1.0,
        energy_source =
        {
            type = "electric",
            usage_priority = "secondary-input",
            emissions_per_minute = 10
        },
        energy_usage = "20MW",
        ingredient_count = 6,
        module_specification =
        {
            module_slots = 4
        },
    allowed_effects = {"consumption", "speed", "pollution"},
    open_sound = { filename = "__base__/sound/machine-open.ogg", volume = 0.75 },
    close_sound = { filename = "__base__/sound/machine-close.ogg", volume = 0.75 },
    },
the recipe:

Code: Select all

{
    type = "recipe",
    name = "sand-to-matter",
    category = "matter-extraction",
    icon = krastorio_recipes_icon_path .. "sand-m.png",
    icon_size = 32,
    energy_required = 2,
    enabled = false,
    hidden = true,
    ingredients =
    {
      {"sand", 50},
    },
    results=
    {
      {type="fluid", name="k-matter", amount=10}
    },
    subgroup = "matter-re",
    order = "z[sand-to-matter]",
    },
Attached two save games, test_kras is from 0.17.64 and will work when loaded in 0.17.65. test_kras2 is from 0.17.65 and will still be broken when loaded in 0.17.65.

Re: [Dominik][0.17.64] When pipe is built before furnace, furnace cannot output to pipe/fluid disappears

Posted: Wed Aug 14, 2019 2:22 pm
by Dominik
This is actually a very funny bug. It is caused by an oversimplification and asymmetry of the current fluid algorithm and a very special combination of the pipe order and fluid batch size and some constants of the algo. Notice that if you put the pipe to the left of the machine, it will work again.
I will put it to won't fix since fixing it would hit performance significantly and it won't be an issue with the new fluid algo once it comes.

Re: [Dominik][0.17.64] When pipe is built before furnace, furnace cannot output to pipe/fluid disappears

Posted: Wed Aug 14, 2019 3:47 pm
by Dominik
I figured out a fix for it with low performance impact. It is ugly but since it will (hopefully) soon all be replaced, then what the fuck.