Page 1 of 1

'Given force is not valid'

Posted: Thu Jan 14, 2016 1:34 am
by memcallen
I'm trying to make one of my entities explode when something happens (currently, placing), but I can't figure out how to make it explode. I tried grenades, but those kill the player as well. entity.die() doesn't work because it doesn't produce the explosion. And entity.damage doesn't work because the game doesn't like the force 'game.forces.enemy'. This is the code that is supposed to kill the entity:

Code: Select all

c.damage(game.forces.enemy, 80) -- c is my entity

Re: 'Given force is not valid'

Posted: Thu Jan 14, 2016 1:49 am
by prg
The force should be the second parameter, not the first.

Re: 'Given force is not valid'

Posted: Thu Jan 14, 2016 1:55 am
by memcallen
...

After testing it, it does the same thing as .die(), how can I make it explode?

Re: 'Given force is not valid'

Posted: Thu Jan 14, 2016 8:36 am
by prg
Does the entity have a dying_explosion? It should explode just fine with .die() then.

Re: 'Given force is not valid'

Posted: Thu Jan 14, 2016 8:31 pm
by memcallen
.die() doesn't work properly, but I ended up just spawning a medium-explosion entity. It contains the sound and everything.

Re: 'Given force is not valid'

Posted: Thu Jan 14, 2016 9:04 pm
by prg
Works fine for me. You do have something like dying_explosion="medium-explosion" in the prototype definition, right? What type of entity is it? Could you post the whole code for the prototype of the entity that's refusing to explode?

Re: 'Given force is not valid'

Posted: Thu Jan 14, 2016 9:36 pm
by memcallen
It's supposed to be a lava pump, that only works with my tiles. But it pumps lava out of water tiles too, so I wanted to make it explode without harming the player if you put it in water. Same with the normal pumps + lava tiles.

Code: Select all

{
    type = "offshore-pump",
    name = "lava-pump",
    icon = "__base__/graphics/icons/offshore-pump.png",
    flags = {"placeable-neutral", "player-creation", "filter-directions"},
    minable = {mining_time = 1, result = "lava-pump"},
    max_health = 80,
    corpse = "small-remnants",
    fluid = "lava",
    resistances =
    {
      {
        type = "fire",
        percent = 90
      }
    },
    collision_box = {{-0.6, -0.3}, {0.6, 0.3}},
    selection_box = {{-1, -1.49}, {1, 0.49}},
    fluid_box =
    {
      base_area = 1,
      pipe_covers = pipecoverspictures(),
      pipe_connections =
      {
        { position = {0, 1} },
      },
    },
    pumping_speed = 1,
    tile_width = 1,
    vehicle_impact_sound =  { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
    picture =
    {
      north =
      {
        filename = "__base__/graphics/entity/offshore-pump/offshore-pump.png",
        priority = "high",
        shift = {0.9, 0.05},
        width = 160,
        height = 102
      },
      east =
      {
        filename = "__base__/graphics/entity/offshore-pump/offshore-pump.png",
        priority = "high",
        shift = {0.9, 0.05},
        x = 160,
        width = 160,
        height = 102
      },
      south =
      {
        filename = "__base__/graphics/entity/offshore-pump/offshore-pump.png",
        priority = "high",
        shift = {0.9, 0.65},
        x = 320,
        width = 160,
        height = 102
      },
      west =
      {
        filename = "__base__/graphics/entity/offshore-pump/offshore-pump.png",
        priority = "high",
        shift = {1.0, 0.05},
        x = 480,
        width = 160,
        height = 102
      }
    },
    circuit_wire_connection_points =
    {
      {
        shadow =
        {
          red = {2.7125, 0.20625},
          green = {2.7125, 0.20625},
        },
        wire =
        {
          red = {0.4, -0.41875},
          green = {0.4, -0.41875},
        }
      },
      {
        shadow =
        {
          red = {2.025, 0.83125},
          green = {2.025, 0.83125},
        },
        wire =
        {
          red = {0.36875, -0.1375},
          green = {0.36875, -0.1375},
        }
      },
      {
        shadow =
        {
          red = {1.09, 1.025},
          green = {1.09, 1.025},
        },
        wire =
        {
          red = {-0.50625, 0.2125},
          green = {-0.50625, 0.2125},
        }
      },
      {
        shadow =
        {
          red = {1.6875, -0.10625},
          green = {1.6875, -0.10625},
        },
        wire =
        {
          red = {-0.34375, -0.73125},
          green = {-0.34375, -0.73125},
        }
      }
    },
    circuit_wire_max_distance = 7.5

  }

Re: 'Given force is not valid'

Posted: Thu Jan 14, 2016 9:55 pm
by prg
Okay, this doesn't contain dying_explosion. It's exploding just fine for me if I add that key to the definition. You tried that too and it doesn't for you?

Re: 'Given force is not valid'

Posted: Thu Jan 14, 2016 10:20 pm
by memcallen
Huh, it works with it now. Maybe I miss-typed something before?