How do I make a throwable light source?

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:

How do I make a throwable light source?

Post by memcallen »

I'm trying to make a glow stick for my mod, but I can't make it 'do nothing'. I tried an empty quote mark, but the game just crashes.

Code: Select all

{
    type = "projectile",
    name = "glowstick",
    flags = {"not-on-map"},
    acceleration = 0.005,
    action =
    {
      {
        type = "direct",
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
            type = "create-entity",
            entity_name = "" -- crashes
            }
          }
        }
      },
      {
        type = "area",
        perimeter = 6.5,
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            
            type = "create-entity",
            entity_name = "" -- crashes
          }
        }
      }
    },
    light = {intensity = 20, size = 4},
    animation =
    {
      filename = "__Caves__/graphics/icons/glowstick.png",
      frame_count = 1,
      width = 32,
      height = 32,
      priority = "high"
    },
    shadow =
    {
      filename = "__base__/graphics/entity/basic-grenade/basic-grenade-shadow.png",
      frame_count = 1,
      width = 24,
      height = 32,
      priority = "high"
    }
  }
How can I make it so my glow stick technically does nothing?

Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: How do I make a throwable light source?

Post by Supercheese »

Try making a new entity with null graphics (e.g. 1x1 transparent pixel .png) and have the glowstick create that entity. (You'll probably want to base this null entity off of a timed-life entity like an explosion or smoke or something.)

In my Orbital Ion Cannon mod (see signature), I take a similar approach for playing sound effects -- since there is no proper way to trigger a notification sound effect for players, I have to spawn an explosion with null graphics at the player's position with the associated sound effect.

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

Re: How do I make a throwable light source?

Post by memcallen »

Thanks, it works now.

Post Reply

Return to “Modding help”