Invisible fires?

Place to get help with not working mods / modding interface.
Post Reply
Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Invisible fires?

Post by Pi-C »

Consider this picture:
fire.png
fire.png (3.65 MiB) Viewed 2427 times
The red dots mark places where a "fire" entity has been found before. I check in on_entity_damaged if such a red dot has been hit by the water turret, and if so, I use

Code: Select all

local function dummy_marks_fire(dummy)
    -- Check argument
    if not (dummy and dummy.valid) then
        error("Wrong arguments for function dummy_marks_fire(dummy): Dummy is not valid!\n")
    end

    local fires = dummy.surface.find_entities_filtered{
        type = "fire",
        position = dummy.position,
        radius = WT.fire_dummy_radius,
    }
    WT.show("Fires found around " .. WT.print_name_id(dummy), fires and table_size(fires))
    if table_size(fires) == 0 then
        dummy.destroy()
        return nil
    end
    return fires
end
to check if any "fire" entities are near that position. If not, the marker should be removed and the turret should proceed with the next target.

This works if there are just one or two markers, but the picture shows a situation where the markers remain in place because fire is found:

Code: Select all

 487.556 Script @__WaterTurret__/common.lua:38: Entered function dummy_marks_fire(fire-dummy (208)) on tick 19438.
 487.556 Script @__WaterTurret__/common.lua:38: Fires found around fire-dummy (208): 1
 487.556 Script @__WaterTurret__/common.lua:38: fires: {
  {
    __self = "userdata"
  }
}
 487.557 Script @__WaterTurret__/common.lua:38: End of function dummy_marks_fire(fire-dummy (208)) on tick 19438. 
 
However, there is no fire visible near any of the dots! Could it be possible that fire entities are invisible, or is there something wrong with my code (guess that's more likely)?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Invisible fires?

Post by Klonan »

Could it be possible that fire entities are invisible
Its possible, can you post your whole fire prototype?

Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Invisible fires?

Post by Pi-C »

Klonan wrote:
Tue Mar 10, 2020 12:40 pm
Could it be possible that fire entities are invisible
Its possible, can you post your whole fire prototype?
I don't really have one. This part of the mod is about extinguishing fires, not creating new ones. I'm just looking for all entities from prototypes with "type = 'fire'", so I can act on every fire entity -- be they vanilla or modded.

I've just deactivated all mods (Creative mod and Natural evolution were on before) except the one I'm testing. It hasn't changed anything, though, fires are still found although none can be seen.

Here's a dump of the entity found, "fire-flame" -- which should be the vanilla variety:

Code: Select all

"fire-flame: "{
  add_fuel_cooldown = 10,
  burnt_patch_alpha_default = 0.4,
  burnt_patch_alpha_variations = {
    {
      alpha = 0.26000000000000001,
      tile = "stone-path"
    },
    {
      alpha = 0.23999999999999999,
      tile = "concrete"
    }
  },
  burnt_patch_lifetime = 1800,
  burnt_patch_pictures = {
    {
      filename = "__base__/graphics/entity/fire-flame/burnt-patch.png",
      height = 56,
      shift = {
        -0.09375,
        0.125
      },
      width = 115,
      x = 0,
      y = 0
    },
    {
      filename = "__base__/graphics/entity/fire-flame/burnt-patch.png",
      height = 56,
      shift = nil,
      width = 115,
      x = 115,
      y = 0
    },
    {
      filename = "__base__/graphics/entity/fire-flame/burnt-patch.png",
      height = 56,
      shift = nil,
      width = 115,
      x = 230,
      y = 0
    },
    {
      filename = "__base__/graphics/entity/fire-flame/burnt-patch.png",
      height = 56,
      shift = nil,
      width = 115,
      x = 0,
      y = 56
    },
    {
      filename = "__base__/graphics/entity/fire-flame/burnt-patch.png",
      height = 56,
      shift = nil,
      width = 115,
      x = 115,
      y = 56
    },
    {
      filename = "__base__/graphics/entity/fire-flame/burnt-patch.png",
      height = 56,
      shift = nil,
      width = 115,
      x = 230,
      y = 56
    },
    {
      filename = "__base__/graphics/entity/fire-flame/burnt-patch.png",
      height = 56,
      shift = nil,
      width = 115,
      x = 0,
      y = 112
    },
    {
      filename = "__base__/graphics/entity/fire-flame/burnt-patch.png",
      height = 56,
      shift = nil,
      width = 115,
      x = 115,
      y = 112
    },
    {
      filename = "__base__/graphics/entity/fire-flame/burnt-patch.png",
      height = 56,
      shift = nil,
      width = 115,
      x = 230,
      y = 112
    }
  },
  damage_multiplier_decrease_per_tick = 0.005,
  damage_multiplier_increase_per_added_fuel = 1,
  damage_per_tick = {
    amount = 0.2166666666666667,
    type = "fire"
  },
  delay_between_initial_flames = 10,
  emissions_per_second = 0.005,
  fade_in_duration = 30,
  fade_out_duration = 30,
  flags = {
    "placeable-off-grid",
    "not-on-map"
  },
  flame_alpha = 0.35,
  flame_alpha_deviation = 0.05,
  initial_lifetime = 120,
  lifetime_increase_by = 150,
  lifetime_increase_cooldown = 4,
  light = {
    intensity = 1,
    size = 20
  },
  maximum_damage_multiplier = 6,
  maximum_lifetime = 1800,
  maximum_spread_count = 100,
  name = "fire-flame",
  on_fuel_added_action = {
    action_delivery = {
      target_effects = {
        {
          offset_deviation = {
            {
              -0.5,
              -0.5
            },
            {
              0.5,
              0.5
            }
          },
          smoke_name = "fire-smoke-on-adding-fuel",
          speed_from_center = 0.01,
          type = "create-trivial-smoke"
        }
      },
      type = "instant"
    },
    type = "direct"
  },
  pictures = {
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-13.png",
      flags = {
        "compressed"
      },
      frame_count = 25,
      height = 118,
      line_length = 8,
      scale = 0.5,
      shift = {
        -0.01953125,
        -0.453125
      },
      tint = {
        a = 1,
        b = 1,
        g = 1,
        r = 1
      },
      width = 60
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-12.png",
      flags = nil,
      frame_count = 25,
      height = 116,
      line_length = 8,
      scale = 0.5,
      shift = {
        -0.0078125,
        -0.45703250000000004
      },
      tint = nil,
      width = 63
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-11.png",
      flags = nil,
      frame_count = 25,
      height = 122,
      line_length = 8,
      scale = 0.5,
      shift = {
        -0.00390625,
        -0.453125
      },
      tint = nil,
      width = 61
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-10.png",
      flags = nil,
      frame_count = 25,
      height = 108,
      line_length = 8,
      scale = 0.5,
      shift = {
        -0.03125,
        -0.32422
      },
      tint = nil,
      width = 65
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-09.png",
      flags = nil,
      frame_count = 25,
      height = 101,
      line_length = 8,
      scale = 0.5,
      shift = {
        -0.015625,
        -0.3476575
      },
      tint = nil,
      width = 64
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-08.png",
      flags = nil,
      frame_count = 32,
      height = 98,
      line_length = 8,
      scale = 0.5,
      shift = {
        -0.02734375,
        -0.38672000000000001
      },
      tint = nil,
      width = 50
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-07.png",
      flags = nil,
      frame_count = 32,
      height = 84,
      line_length = 8,
      scale = 0.5,
      shift = {
        0.0078125,
        -0.3203125
      },
      tint = nil,
      width = 54
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-06.png",
      flags = nil,
      frame_count = 32,
      height = 92,
      line_length = 8,
      scale = 0.5,
      shift = {
        0,
        -0.41797000000000004
      },
      tint = nil,
      width = 65
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-05.png",
      flags = nil,
      frame_count = 32,
      height = 103,
      line_length = 8,
      scale = 0.5,
      shift = {
        0.015625,
        -0.44140750000000004
      },
      tint = nil,
      width = 59
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-04.png",
      flags = nil,
      frame_count = 32,
      height = 130,
      line_length = 8,
      scale = 0.5,
      shift = {
        0.0078125,
        -0.5546875
      },
      tint = nil,
      width = 67
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-03.png",
      flags = nil,
      frame_count = 32,
      height = 117,
      line_length = 8,
      scale = 0.5,
      shift = {
        0.0234375,
        -0.4921875
      },
      tint = nil,
      width = 74
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-02.png",
      flags = nil,
      frame_count = 32,
      height = 114,
      line_length = 8,
      scale = 0.5,
      shift = {
        0.00390625,
        -0.484375
      },
      tint = nil,
      width = 74
    },
    {
      animation_speed = 1,
      axially_symmetrical = false,
      blend_mode = "normal",
      direction_count = 1,
      filename = "__base__/graphics/entity/fire-flame/fire-flame-01.png",
      flags = nil,
      frame_count = 32,
      height = 119,
      line_length = 8,
      scale = 0.5,
      shift = {
        -0.03515625,
        -0.51953249999999995
      },
      tint = nil,
      width = 66
    }
  },
  smoke = {
    {
      deviation = {
        0.5,
        0.5
      },
      frequency = 0.125,
      height = -0.5,
      name = "fire-smoke",
      position = {
        0,
        -0.8
      },
      starting_frame_deviation = 60,
      starting_vertical_speed = 0.05,
      starting_vertical_speed_deviation = 0.005,
      vertical_speed_slowdown = 0.99000000000000004
    }
  },
  smoke_source_pictures = {
    {
      animation_speed = 0.5,
      filename = "__base__/graphics/entity/fire-flame/fire-smoke-source-1.png",
      frame_count = 31,
      height = 138,
      line_length = 8,
      shift = {
        -0.109375,
        -1.1875
      },
      width = 101
    },
    {
      animation_speed = 0.5,
      filename = "__base__/graphics/entity/fire-flame/fire-smoke-source-2.png",
      frame_count = 31,
      height = 138,
      line_length = 8,
      shift = {
        -0.203125,
        -1.21875
      },
      width = 99
    }
  },
  spawn_entity = "fire-flame-on-tree",
  spread_delay = 300,
  spread_delay_deviation = 180,
  type = "fire",
  working_sound = {
    fade_in_ticks = 10,
    fade_out_ticks = 90,
    max_sounds_per_type = 3,
    sound = {
      {
        filename = "__base__/sound/fire-1.ogg",
        volume = 0.7
      },
      {
        filename = "__base__/sound/fire-2.ogg",
        volume = 0.7
      }
    }
  }
}"
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Invisible fires?

Post by Honktown »

Not likely, but, double-check WT.fire_dummy_radius. If it is nil, the whole surface may be being searched instead (api page isn't explicit on position and no other limiter). I say not likely because all the dots would probably disappear after the last fire was extinguished, which you'd probably notice.
I have mods! I guess!
Link

Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Invisible fires?

Post by Pi-C »

Honktown wrote:
Tue Mar 10, 2020 6:19 pm
Not likely, but, double-check WT.fire_dummy_radius. If it is nil, the whole surface may be being searched instead (api page isn't explicit on position and no other limiter).
Thanks, but I just confirmed that the variable has been set (radius = 2).
I say not likely because all the dots would probably disappear after the last fire was extinguished, which you'd probably notice.
The dots are of the type "simple-entity-with-force", so once they've died, they are gone. Also, during targetting, these markers are the last thing that the script is looking for, so real enemies will be chosen first, the markers only if there are no enemies. The only problem is that it will look strange if a turret decides it should attack a marker if there is no fire around it -- as a player knowing nothing about the internal workings of the mod, I'd wonder why the turret suddenly sprays empty ground with water ("empty ground" because the dots are only shown in debug mode, normally they have just a blank picture).
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Invisible fires?

Post by Honktown »

Pi-C wrote:
Tue Mar 10, 2020 6:34 pm
The dots are of the type "simple-entity-with-force", so once they've died, they are gone. Also, during targetting, these markers are the last thing that the script is looking for, so real enemies will be chosen first, the markers only if there are no enemies. The only problem is that it will look strange if a turret decides it should attack a marker if there is no fire around it -- as a player knowing nothing about the internal workings of the mod, I'd wonder why the turret suddenly sprays empty ground with water ("empty ground" because the dots are only shown in debug mode, normally they have just a blank picture).
...could you replace the marker with a tiny animation of fire. The "embers" that the turret extinguishes to keep the fire from "returning?".
I have mods! I guess!
Link

Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Invisible fires?

Post by Pi-C »

Honktown wrote:
Tue Mar 10, 2020 6:44 pm
...could you replace the marker with a tiny animation of fire. The "embers" that the turret extinguishes to keep the fire from "returning?".
Not optimal -- what happens if some marker gets placed just out of reach of the turret? Could happen, and shouldn't matter much because the script is supposed to clean left-over markers from the surface in regular intervals (hourly or so). But it would look bad if there's some dummy flame that doesn't burn or hurt anything for a long time. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Invisible fires?

Post by Honktown »

Pi-C wrote:
Tue Mar 10, 2020 7:13 pm
Honktown wrote:
Tue Mar 10, 2020 6:44 pm
...could you replace the marker with a tiny animation of fire. The "embers" that the turret extinguishes to keep the fire from "returning?".
Not optimal -- what happens if some marker gets placed just out of reach of the turret? Could happen, and shouldn't matter much because the script is supposed to clean left-over markers from the surface in regular intervals (hourly or so). But it would look bad if there's some dummy flame that doesn't burn or hurt anything for a long time. :-)
Makes sense. It was just literally my first thought: "if it sticks around too long and the turret may fire at it, let's just pretend that is intended..."
I have mods! I guess!
Link

Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Invisible fires?

Post by Pi-C »

Honktown wrote:
Tue Mar 10, 2020 7:30 pm
Makes sense. It was just literally my first thought: "if it sticks around too long and the turret may fire at it, let's just pretend that is intended..."
Perhaps I could replace the marker with a bunch of flowers when it's dead. Then it would at least make sense that the turret has watered empty ground. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Invisible fires?

Post by eradicator »

Klonan wrote:
Tue Mar 10, 2020 12:40 pm
Could it be possible that fire entities are invisible
Its possible, can you post your whole fire prototype?
Using my mod /sudo to attach a bunch of custom renders to fires created by the vanilla flamethrower i can definetly see that the fire entities continue to exist 15~45 seconds after visually disappearing

Code: Select all

--attach a circle render to all fire types in radius 20 around the player
/sudo for _,v in pairs(find{type='fire',area=around(here,20)}) do blip(v,50000) end
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Invisible fires?

Post by Pi-C »

Honktown wrote:
Tue Mar 10, 2020 6:44 pm
...could you replace the marker with a tiny animation of fire. The "embers" that the turret extinguishes to keep the fire from "returning?".
Actually, this may be a possibility -- if combined with an idea by eradicator: to use a self-expiring prototype (like a combat robot) for the marker. The problem with that is that I can't get the new prototype to take damage:

Code: Select all

local fire_dummy = util.table.deepcopy(data.raw[WT.fire_dummy_type]["defender"])
fire_dummy.name = WT.fire_dummy_name
fire_dummy.max_health = 2
fire_dummy.flags = {
        "placeable-off-grid",
        "not-repairable",
        "not-on-map",
        "not-blueprintable",
        "not-deconstructable",
        "hidden",
        "not-flammable",
        "no-copy-paste",
        "not-selectable-in-game"
    }
fire_dummy.max_speed = 0
fire_dummy.speed = 0
fire_dummy.max_to_charge = 0
fire_dummy.speed_multiplier_when_out_of_energy = 1
fire_dummy.water_reflection = nil
fire_dummy.working_sound = nil
fire_dummy.dying_explosion = nil
fire_dummy.dying_trigger_effect = nil
fire_dummy.follows_player = false
fire_dummy.attack_parameters.ammo_type.action.action_delivery = nil
fire_dummy.icon = mods["_debug"] and MOD_PIX .. "/red_dot.png" or MOD_PIX .. "/blank.png"
fire_dummy.icon_mipmaps = 4
fire_dummy.icon_size = 64
fire_dummy.destroy_action = nil

data:extend({ fire_dummy })

For testing, I changed the resistances to

Code: Select all

data.raw[WT.fire_dummy_type][WT.fire_dummy_name].resistances = {
	{
	        type = "fire",
	        decrease = 0,
        	percent = 100
        }
}
so that the marker doesn't get destroyed by the fire around it. I listen to on_entity_damaged, filtered by the damage done by the turret. However, the function that's called by this event is never entered. The damage dealt by the turret is only minute, but it always triggered the event with the old prototype. I could kill the marker with my character (without entering on_entity_damaged, though, because even a pistol with simple ammo deals enough damage to kill the entity immediately). There still must be something I don't see…
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Invisible fires?

Post by Honktown »

Pi-C wrote:
Thu Mar 12, 2020 6:19 pm
...
There is on_entity_died. Not saying with any certainty, but I wonder if an entity going from max to 0 fires an on_entity_damaged event (or any health to 0). I could see a subtle case where it isn't (it died, it didn't live after being hit).

Is the code posted anywhere? I would like to test things if you wouldn't mind. I see water turret but this new thing is still experimental, right?
I have mods! I guess!
Link

Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Invisible fires?

Post by Pi-C »

Honktown wrote:
Thu Mar 12, 2020 9:59 pm
There is on_entity_died. Not saying with any certainty, but I wonder if an entity going from max to 0 fires an on_entity_damaged event (or any health to 0). I could see a subtle case where it isn't (it died, it didn't live after being hit).
I know, but it's not really useful in the non-testing setup: The marker has only 2 health maximum because water does only 0.005 damage, so it takes 200 ticks until it dies. After the marker is dead, I use on_entity_died to remove all fires around the marker (it wouldn't be realistic if the first hit would extinguish a whole patch of fires). I need on_entity_damaged so I can check whether it's really worth to proceed or if the marker doesn't mark anything and should be removed immediately.
Is the code posted anywhere? I would like to test things if you wouldn't mind. I see water turret but this new thing is still experimental, right?
Right, the version available on the mod portal doesn't have any of the new code yet, it's just prototype stuff currently, without the new control.lua stuff.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Invisible fires?

Post by Honktown »

Updating. Pi-C and I had some back-and-forth messages, and there were two things: the burn spot on the ground is still the fire entity (burnt_patch_lifetime is in fire-flame), and the water stream (.action entry) needed "ignore_collision_condition = true,", as the dummys have a 0x0 collision box. Water Turret has the new feature, now.
I have mods! I guess!
Link

Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Invisible fires?

Post by Pi-C »

Honktown wrote:
Wed Mar 18, 2020 5:56 pm
Updating. Pi-C and I had some back-and-forth messages, and there were two things: the burn spot on the ground is still the fire entity (burnt_patch_lifetime is in fire-flame), and the water stream (.action entry) needed "ignore_collision_condition = true,", as the dummys have a 0x0 collision box. Water Turret has the new feature, now.
Yikes, should have added that myself! I did mention the burnt_patch_lifetime at least in another thread already, just forgot to write about it here … :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Post Reply

Return to “Modding help”