[Resolved]How do I use my own projectile?

Place to get help with not working mods / modding interface.
Post Reply
shandrolis
Burner Inserter
Burner Inserter
Posts: 12
Joined: Thu Aug 13, 2015 2:52 pm
Contact:

[Resolved]How do I use my own projectile?

Post by shandrolis »

Hello there!
This is my first go at modding, and I'm basically trying to make a better (if a little overpowered :P ) version of the basic grenade, called ' advanced grenade' .
Reason I'm trying to make it, is to easily clear trees :P
I'm aware there is a Thermite mod for that (or ofcourse the vanilla way, construction robots), but it seemed like a good opportunity to teach myself to to make my own mod.

My problem is that I can't figure out how to use my own projectile.
I can make my custom item throw the basic grenade projectile, just not my own.
Whenever I add "advanced-grenade-projectile" at

Code: Select all

ammo_type =
        {
          category = "capsule",
          target_type = "position",
          action =
          {
            type = "direct",
            action_delivery =
            {
              type = "projectile",
              projectile = "advanced-grenade-projectile",
              starting_speed = 0.6
            }
          }
        }
,
I get the following error:
Image



If someone could help me figure out what I'm doing wrong it'd be greatly appreciated! :D
Full Code below.

info.json

Code: Select all

require("prototypes.item")
require("prototypes.recipe")
require("prototypes.projectile")

item.lua

Code: Select all

data:extend({

  {
    type = "capsule",
    name = "advanced-grenade",
    icon = "__base__/graphics/icons/basic-grenade.png",
    flags = {"goes-to-quickbar"},
    capsule_action =
    {
      type = "throw",
      attack_parameters =
      {
        type = "projectile",
        ammo_category = "capsule",
        cooldown = 5,
        projectile_creation_distance = 0.6,
        range = 50,
        ammo_type =
        {
          category = "capsule",
          target_type = "position",
          action =
          {
            type = "direct",
            action_delivery =
            {
              type = "projectile",
              projectile = "advanced-grenade-projectile",
              starting_speed = 0.6
            }
          }
        }
      }
    },
    subgroup = "capsule",
    order = "a[basic-grenade]",
    stack_size = 100
  }
  })
  
recipe.lua

Code: Select all

data:extend({

{
    type = "recipe",
    name = "advanced-grenade",
    enabled = "true",
    ingredients = 
   {
      {"coal", 1},
   },
    result = "advanced-grenade"
  },  
})
projectile.lua

Code: Select all

data:extend(
    {
    type = "projectile",
    name = "advanced-grenade-projectile",
    flags = {"not-on-map"},
    acceleration = 0.03,
    action =
    {
      {
        type = "direct",
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
            type = "create-entity",
            entity_name = "massive-explosion"
            },
            {
            type = "create-entity",
            entity_name = "medium-scorchmark",
            check_buildability = true
            }
          }
        }
      },
      {
        type = "area",
        perimeter = 16.5,
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
            type = "damage",
            damage = {amount = 80, type = "explosion"}
            },
            {
            type = "create-entity",
            entity_name = "explosion"
            }
          }
        }
      }
    },
    light = {intensity = 0.5, size = 4},
    animation =
    {
      filename = "__base__/graphics/entity/basic-grenade/basic-grenade.png",
      frame_count = 1,
      width = 24,
      height = 24,
      priority = "high"
    },
    shadow =
    {
      filename = "__base__/graphics/entity/basic-grenade/basic-grenade-shadow.png",
      frame_count = 1,
      width = 24,
      height = 32,
      priority = "high"
    }
  }
  )

Last edited by shandrolis on Wed Apr 20, 2016 11:58 pm, edited 1 time in total.

User avatar
Galacticruler
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Sat Apr 16, 2016 5:18 pm
Contact:

Re: How do I use my own projectile?

Post by Galacticruler »

have you tried re-ordering the requires list so projectiles loads first?
PC is best.

shandrolis
Burner Inserter
Burner Inserter
Posts: 12
Joined: Thu Aug 13, 2015 2:52 pm
Contact:

Re: How do I use my own projectile?

Post by shandrolis »

Galacticruler wrote:have you tried re-ordering the requires list so projectiles loads first?
Still the same error :/

shandrolis
Burner Inserter
Burner Inserter
Posts: 12
Joined: Thu Aug 13, 2015 2:52 pm
Contact:

Re: How do I use my own projectile?

Post by shandrolis »

Anyone else have an idea on this? I'm at a loss.

slindenau
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 25, 2016 1:46 pm
Contact:

Re: How do I use my own projectile?

Post by slindenau »

You need one more set of curly brackets in your data.extend call. The function expects a table of prototypes.
And there is no "medium-scorchmark" so it seems. You could extend your own perhaps :)? Example in ~\prototypes\entity\demo-remnants.lua

This loads for me:

projectile.lua

Code: Select all

data:extend(
{
    {
    type = "projectile",
    name = "advanced-grenade-projectile",
    flags = {"not-on-map"},
    acceleration = 0.03,
    action =
    {
      {
        type = "direct",
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
            type = "create-entity",
            entity_name = "massive-explosion"
            },
            {
            type = "create-entity",
            entity_name = "small-scorchmark",
            check_buildability = true
            }
          }
        }
      },
      {
        type = "area",
        perimeter = 16.5,
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
            type = "damage",
            damage = {amount = 80, type = "explosion"}
            },
            {
            type = "create-entity",
            entity_name = "explosion"
            }
          }
        }
      }
    },
    light = {intensity = 0.5, size = 4},
    animation =
    {
      filename = "__base__/graphics/entity/basic-grenade/basic-grenade.png",
      frame_count = 1,
      width = 24,
      height = 24,
      priority = "high"
    },
    shadow =
    {
      filename = "__base__/graphics/entity/basic-grenade/basic-grenade-shadow.png",
      frame_count = 1,
      width = 24,
      height = 32,
      priority = "high"
    }
  }
  }
  )
My mod: "Auto Deploy Destroyers" (follower robots) viewtopic.php?f=97&t=24545

shandrolis
Burner Inserter
Burner Inserter
Posts: 12
Joined: Thu Aug 13, 2015 2:52 pm
Contact:

Re: How do I use my own projectile?

Post by shandrolis »

slindenau wrote:You need one more set of curly brackets in your data.extend call. The function expects a table of prototypes.
And there is no "medium-scorchmark" so it seems. You could extend your own perhaps :)? Example in ~\prototypes\entity\demo-remnants.lua

This loads for me:

projectile.lua

Code: Select all

data:extend(
{
    {
    type = "projectile",
    name = "advanced-grenade-projectile",
    flags = {"not-on-map"},
    acceleration = 0.03,
    action =
    {
      {
        type = "direct",
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
            type = "create-entity",
            entity_name = "massive-explosion"
            },
            {
            type = "create-entity",
            entity_name = "small-scorchmark",
            check_buildability = true
            }
          }
        }
      },
      {
        type = "area",
        perimeter = 16.5,
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
            type = "damage",
            damage = {amount = 80, type = "explosion"}
            },
            {
            type = "create-entity",
            entity_name = "explosion"
            }
          }
        }
      }
    },
    light = {intensity = 0.5, size = 4},
    animation =
    {
      filename = "__base__/graphics/entity/basic-grenade/basic-grenade.png",
      frame_count = 1,
      width = 24,
      height = 24,
      priority = "high"
    },
    shadow =
    {
      filename = "__base__/graphics/entity/basic-grenade/basic-grenade-shadow.png",
      frame_count = 1,
      width = 24,
      height = 32,
      priority = "high"
    }
  }
  }
  )


Oh my god how did I miss that lol. Thanks!
Anyone got a good IDE for this that tells me when I do stupid stuff like this? ^_^

Post Reply

Return to “Modding help”