'Given force is not valid'

Place to get help with not working mods / modding interface.
Post Reply
memcallen
Inserter
Inserter
Posts: 34
Joined: Sat Mar 28, 2015 1:22 am
Contact:

'Given force is not valid'

Post 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

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: 'Given force is not valid'

Post by prg »

The force should be the second parameter, not the first.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

memcallen
Inserter
Inserter
Posts: 34
Joined: Sat Mar 28, 2015 1:22 am
Contact:

Re: 'Given force is not valid'

Post by memcallen »

...

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

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: 'Given force is not valid'

Post by prg »

Does the entity have a dying_explosion? It should explode just fine with .die() then.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

memcallen
Inserter
Inserter
Posts: 34
Joined: Sat Mar 28, 2015 1:22 am
Contact:

Re: 'Given force is not valid'

Post by memcallen »

.die() doesn't work properly, but I ended up just spawning a medium-explosion entity. It contains the sound and everything.

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: 'Given force is not valid'

Post 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?
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

memcallen
Inserter
Inserter
Posts: 34
Joined: Sat Mar 28, 2015 1:22 am
Contact:

Re: 'Given force is not valid'

Post 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

  }

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: 'Given force is not valid'

Post 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?
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

memcallen
Inserter
Inserter
Posts: 34
Joined: Sat Mar 28, 2015 1:22 am
Contact:

Re: 'Given force is not valid'

Post by memcallen »

Huh, it works with it now. Maybe I miss-typed something before?

Post Reply

Return to “Modding help”