Page 1 of 1

Bads with adding assembling entity and crafting category

Posted: Thu Jan 19, 2023 12:54 am
by DemerNkardaz
I added entity-copy of boiler and change some parameters to make it a craft-machine for new liquid and other planned crafts. But it is invisible and does not have recipes (recipe exists ingame).
Image

Recipe - ex/ore_resin_recipes.lua

Code: Select all

	{
	type = "recipe",
	name = "PLORD_resin_melting_processing",
	localised_name = {"", "[fluid=PLORD_resin_melted]", {"recipe-name.PLORD_resin_melting_processing"}},
	category = "chemistry-boiler-crafts",
	enabled = true,
	energy_required = 5,
	ingredients =
	{
		{type="item", name="PLORD_resin_ore", amount=50},
	},
	results=
	{
		{type="fluid", name="PLORD_resin_melted", amount=100},
	},
	icon = "__PLORD__/graphics/icons/fluid/resin-melted.png",
	icon_size = 64, icon_mipmaps = 4,
	subgroup = "fluid-recipes",
	order = "a[chemistry-boiler-crafts]-b[resin-melting]"
	},
ImageImage


Chemical Boiler item - PLORD_items.lua

Code: Select all

data:extend({
  {
    type = "item",
    name = "PLORD_chemical_boiler",
    icon = "__PLORD__/graphics/icons/boiler-chemical.png",
    icon_size = 64, icon_mipmaps = 4,
    subgroup = "production-machine",
    order = "e[chemical-plant]-a[chemical-boiler]",
    place_result = "PLORD_chemical_boiler",
    stack_size = 10
  },
})
Chemical Boiler entity - PLORD_structures.lua

Code: Select all

require ("util")
require ("__base__.prototypes.entity.pipecovers")
require ("__base__.prototypes.entity.transport-belt-pictures")
require ("__base__.prototypes.entity.transport-belt-pictures")
require ("__base__.prototypes.entity.assemblerpipes")
require ("__base__.prototypes.entity.laser-sounds")

local hit_effects = require ("__base__.prototypes.entity.hit-effects")
local sounds = require("__base__.prototypes.entity.sounds")

data:extend({
  {
    type = "assembling-machine",
    name = "PLORD_chemical_boiler",
    icon = "__PLORD__/graphics/icons/boiler-chemical.png",
    icon_size = 64, icon_mipmaps = 4,
    flags = {"placeable-neutral","placeable-player", "player-creation"},
    minable = {mining_time = 0.2, result = "PLORD_chemical_boiler"},
    max_health = 100,
    corpse = "boiler-remnants",
    dying_explosion = "boiler-explosion",
    vehicle_impact_sound = sounds.generic_impact,
    mode = "output-to-separate-pipe",
    module_specification =
    {
      module_slots = 2
    },
    allowed_effects = {"consumption", "speed", "productivity", "pollution"},
    resistances =
    {
      {
        type = "fire",
        percent = 50
      },
      {
        type = "explosion",
        percent = 10
      },
      {
        type = "impact",
        percent = 30
      }
    },
	collision_box = {{-1.29, -0.79}, {1.29, 0.79}},
	selection_box = {{-1.5, -1}, {1.5, 1}},
	damaged_trigger_effect = hit_effects.entity(),
	crafting_speed = 1,
	target_temperature = 125,
	energy_usage = "210kW",
	crafting_categories = {"chemistry-boiler-crafts"},
	energy_source =
	{
		type = "electric",
		input_priority = "secondary",
		usage_priority = "secondary-input",
	{
		color = {0,0,0},
		minimum_intensity = 0.6,
		maximum_intensity = 0.95
	},
	smoke =
	{
	{
		name = "smoke",
		north_position = util.by_pixel(-38, -47.5),
		south_position = util.by_pixel(38.5, -32),
		east_position = util.by_pixel(20, -70),
		west_position = util.by_pixel(-19, -8.5),
		frequency = 15,
		starting_vertical_speed = 0.0,
		starting_frame_deviation = 60
        }
	}
    	},


	fluid_box =
	{
		base_area = 1,
		height = 2,
		base_level = -1,
		pipe_covers = pipecoverspictures(),
		pipe_connections =
		{
			{type = "input-output", position = {-2, 0.5}},
			{type = "input-output", position = {2, 0.5}}
		},
		production_type = "input-output",
	},
	output_fluid_box =
	{
		base_area = 1,
		height = 2,
		base_level = 1,
		pipe_covers = pipecoverspictures(),
		pipe_connections =
		{
			{type = "output", position = {0, -1.5}}
		},
		production_type = "output",
	},
	working_sound =
	{
		sound =
		{
			filename = "__base__/sound/boiler.ogg",
			volume = 0.7
		},
	audible_distance_modifier = 0.3,
	fade_in_ticks = 4,
	fade_out_ticks = 20
	},
	open_sound = sounds.machine_open,
	close_sound = sounds.machine_close,

	structure =
	{
  	    north =
	{
        layers =
        {
          {
            filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-N-idle.png",
            priority = "extra-high",
            width = 131,
            height = 108,
            shift = util.by_pixel(-0.5, 4),
            hr_version =
            {
              filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-N-idle.png",
              priority = "extra-high",
              width = 269,
              height = 221,
              shift = util.by_pixel(-1.25, 5.25),
              scale = 0.5
            }
          },
          {
            filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-N-shadow.png",
            priority = "extra-high",
            width = 137,
            height = 82,
            shift = util.by_pixel(20.5, 9),
            draw_as_shadow = true,
            hr_version =
            {
              filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-N-shadow.png",
              priority = "extra-high",
              width = 274,
              height = 164,
              scale = 0.5,
              shift = util.by_pixel(20.5, 9),
              draw_as_shadow = true
            }
          }
        }
      },
      east =
      {
        layers =
        {
          {
            filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-E-idle.png",
            priority = "extra-high",
            width = 105,
            height = 147,
            shift = util.by_pixel(-3.5, -0.5),
            hr_version =
            {
              filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-E-idle.png",
              priority = "extra-high",
              width = 216,
              height = 301,
              shift = util.by_pixel(-3, 1.25),
              scale = 0.5
            }
          },
          {
            filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-E-shadow.png",
            priority = "extra-high",
            width = 92,
            height = 97,
            shift = util.by_pixel(30, 9.5),
            draw_as_shadow = true,
            hr_version =
            {
              filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-E-shadow.png",
              priority = "extra-high",
              width = 184,
              height = 194,
              scale = 0.5,
              shift = util.by_pixel(30, 9.5),
              draw_as_shadow = true
            }
          }
        }
      },
      south =
      {
        layers =
        {
          {
            filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-S-idle.png",
            priority = "extra-high",
            width = 128,
            height = 95,
            shift = util.by_pixel(3, 12.5),
            hr_version =
            {
              filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-S-idle.png",
              priority = "extra-high",
              width = 260,
              height = 192,
              shift = util.by_pixel(4, 13),
              scale = 0.5
            }
          },
          {
            filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-S-shadow.png",
            priority = "extra-high",
            width = 156,
            height = 66,
            shift = util.by_pixel(30, 16),
            draw_as_shadow = true,
            hr_version =
            {
              filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-S-shadow.png",
              priority = "extra-high",
              width = 311,
              height = 131,
              scale = 0.5,
              shift = util.by_pixel(29.75, 15.75),
              draw_as_shadow = true
            }
          }
        }
      },
      west =
      {
        layers =
        {
          {
            filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-W-idle.png",
            priority = "extra-high",
            width = 96,
            height = 132,
            shift = util.by_pixel(1, 5),
            hr_version =
            {
              filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-W-idle.png",
              priority = "extra-high",
              width = 196,
              height = 273,
              shift = util.by_pixel(1.5, 7.75),
              scale = 0.5
            }
          },
          {
            filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-W-shadow.png",
            priority = "extra-high",
            width = 103,
            height = 109,
            shift = util.by_pixel(19.5, 6.5),
            draw_as_shadow = true,
            hr_version =
            {
              filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-W-shadow.png",
              priority = "extra-high",
              width = 206,
              height = 218,
              scale = 0.5,
              shift = util.by_pixel(19.5, 6.5),
              draw_as_shadow = true
            }
          }
        }
      }
    },

    patch =
    {
      east =
      {
        filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-E-patch.png",
        priority = "extra-high",
        width = 3,
        height = 17,
        shift = util.by_pixel(33.5, -13.5),
        hr_version =
        {
          filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-E-patch.png",
          width = 6,
          height = 36,
          shift = util.by_pixel(33.5, -13.5),
          scale = 0.5
        }
      }
    },

    fire_flicker_enabled = true,
    fire =
    {
      north =
      {
        filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-N-fire.png",
        draw_as_glow = true,
        priority = "extra-high",
        frame_count = 64,
        line_length = 8,
        width = 12,
        height = 13,
        animation_speed = 0.5,
        shift = util.by_pixel(0, -8.5),
        hr_version =
        {
          filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-N-fire.png",
          draw_as_glow = true,
          priority = "extra-high",
          frame_count = 64,
          line_length = 8,
          width = 26,
          height = 26,
          animation_speed = 0.5,
          shift = util.by_pixel(0, -8.5),
          scale = 0.5
        }
      },
      east =
      {
        filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-E-fire.png",
        draw_as_glow = true,
        priority = "extra-high",
        frame_count = 64,
        line_length = 8,
        width = 14,
        height = 14,
        animation_speed = 0.5,
        shift = util.by_pixel(-10, -22),
        hr_version =
        {
          filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-E-fire.png",
          draw_as_glow = true,
          priority = "extra-high",
          frame_count = 64,
          line_length = 8,
          width = 28,
          height = 28,
          animation_speed = 0.5,
          shift = util.by_pixel(-9.5, -22),
          scale = 0.5
        }
      },
      south =
      {
        filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-S-fire.png",
        draw_as_glow = true,
        priority = "extra-high",
        frame_count = 64,
        line_length = 8,
        width = 12,
        height = 9,
        animation_speed = 0.5,
        shift = util.by_pixel(-1, -26.5),
        hr_version =
        {
          filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-S-fire.png",
          draw_as_glow = true,
          priority = "extra-high",
          frame_count = 64,
          line_length = 8,
          width = 26,
          height = 16,
          animation_speed = 0.5,
          shift = util.by_pixel(-1, -26.5),
          scale = 0.5
        }
      },
      west =
      {
        filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-W-fire.png",
        draw_as_glow = true,
        priority = "extra-high",
        frame_count = 64,
        line_length = 8,
        width = 14,
        height = 14,
        animation_speed = 0.5,
        shift = util.by_pixel(13, -23),
        hr_version =
        {
          filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-W-fire.png",
          draw_as_glow = true,
          priority = "extra-high",
          frame_count = 64,
          line_length = 8,
          width = 30,
          height = 29,
          animation_speed = 0.5,
          shift = util.by_pixel(13, -23.25),
          scale = 0.5
        }
      }
    },

    fire_glow_flicker_enabled = true,

    fire_glow =
    {
      north =
      {
        filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-N-light.png",
        draw_as_glow = true,
        priority = "extra-high",
        frame_count = 1,
        width = 100,
        height = 87,
        shift = util.by_pixel(-1, -6.5),
        blend_mode = "additive",
        hr_version =
        {
          filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-N-light.png",
          draw_as_glow = true,
          priority = "extra-high",
          frame_count = 1,
          width = 200,
          height = 173,
          shift = util.by_pixel(-1, -6.75),
          blend_mode = "additive",
          scale = 0.5
        }
      },
      east =
      {
        filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-E-light.png",
        draw_as_glow = true,
        priority = "extra-high",
        frame_count = 1,
        width = 70,
        height = 122,
        shift = util.by_pixel(0, -13),
        blend_mode = "additive",
        hr_version =
        {
          filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-E-light.png",
          draw_as_glow = true,
          priority = "extra-high",
          frame_count = 1,
          width = 139,
          height = 244,
          shift = util.by_pixel(0.25, -13),
          blend_mode = "additive",
          scale = 0.5
        }
      },
      south =
      {
        filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-S-light.png",
        draw_as_glow = true,
        priority = "extra-high",
        frame_count = 1,
        width = 100,
        height = 81,
        shift = util.by_pixel(1, 5.5),
        blend_mode = "additive",
        hr_version =
        {
          filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-S-light.png",
          draw_as_glow = true,
          priority = "extra-high",
          frame_count = 1,
          width = 200,
          height = 162,
          shift = util.by_pixel(1, 5.5),
          blend_mode = "additive",
          scale = 0.5
        }
      },
      west =
      {
        filename = "__PLORD__/graphics/entity/boiler-chemical/boiler-W-light.png",
        draw_as_glow = true,
        priority = "extra-high",
        frame_count = 1,
        width = 68,
        height = 109,
        shift = util.by_pixel(2, -6.5),
        blend_mode = "additive",
        hr_version =
        {
          filename = "__PLORD__/graphics/entity/boiler-chemical/hr-boiler-W-light.png",
          draw_as_glow = true,
          priority = "extra-high",
          frame_count = 1,
          width = 136,
          height = 217,
          shift = util.by_pixel(2, -6.25),
          blend_mode = "additive",
          scale = 0.5
        }
      }
    },
    burning_cooldown = 20,
    water_reflection = boiler_reflection()
  },
})
__PLORD__/graphics/entity/boiler-chemical/
Image

New recipe category - PLORD_categories_recipe.lua

Code: Select all

data:extend({
  {
    type = "recipe-category",
    name = "chemistry-boiler-crafts"
  },
})

Re: Bads with adding assembling entity and crafting category

Posted: Thu Jan 19, 2023 3:05 am
by Silari
The prototypes for boilers and assembling machines are very different - you can't just copy all the data and change the type to have it work. Boilers have their sprites defined in a structure property, assembling machines use an animation property, which have differences in how they are laid out.

Re: Bads with adding assembling entity and crafting category

Posted: Sat Jan 21, 2023 1:54 am
by DemerNkardaz
Silari wrote:
Thu Jan 19, 2023 3:05 am
The prototypes for boilers and assembling machines are very different - you can't just copy all the data and change the type to have it work. Boilers have their sprites defined in a structure property, assembling machines use an animation property, which have differences in how they are laid out.
Thank you. I added flib function using and fix as well invisibility and craft category. But this not making sounds and effects during craft, however it is fixable and need to work on code next.
Image
And I want to make pipe connectors attachable any time and with crafts that not using input ports of chemical boiler, don't know how it be fixed this time.
Image