Combining WaiTex accumulator animation with another mod

Place to get help with not working mods / modding interface.
Dahak
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri Apr 29, 2016 9:19 pm
Contact:

Combining WaiTex accumulator animation with another mod

Post by Dahak »

Does anyone know how to make a layered animation like what WaiTex uses for accumulators work in the prototype data for new items?

I like what the upgraded electric mod does as far as condensing solar fields goes, but the graphics are too garish for me. So I made new ones based on the WaiTex accumulator textures. WaiTex handles the charge/discharge animation differently from vanilla by overlaying the animation onto the accumulator sprite using a script in an overwrite. Which is great and works like a charm for overriding default values, but I can't figure out how to make it work in the prototype file for the upgraded accumulators.

Here is the accumulator code:

Code: Select all

data:extend(
{
  {
    type = "accumulator",
    name = "elite-accumulator",
    icon = "__UpgradedElectric__/graphics/elite-accumulator/elite-accumulator-icon.png",
    flags = {"placeable-neutral", "player-creation"},
    minable = {hardness = 0.2, mining_time = 0.5, result = "elite-accumulator"},
    max_health = 250,
    corpse = "medium-remnants",
    collision_box = {{-0.9, -0.9}, {0.9, 0.9}},
    selection_box = {{-1, -1}, {1, 1}},
    energy_source =
    {
      type = "electric",
      buffer_capacity = "500MJ",
      usage_priority = "terciary",
      input_flow_limit = "30MW",
      output_flow_limit = "30MW"
    },
    picture =
    {
      filename = "__UpgradedElectric__/graphics/elite-accumulator/elite-accumulator.png",
      priority = "extra-high",
      width = 248,
      height = 206,
      scale  = 0.5,	shift = {0.7, -0.2}
    },
    charge_animation =
    {
      filename = "__UpgradedElectric__/graphics/elite-accumulator/elite-accumulator-charge-animation.png",
      width = 276,
      height = 270,
      line_length = 6,
      scale  = 0.5,	frame_count = 24,
      shift = {0.482, -0.638},
      animation_speed = 0.5
    },
    charge_cooldown = 30,
    charge_light = {intensity = 0.3, size = 7},
    discharge_animation =
    {
      filename = "__UpgradedElectric__/graphics/elite-accumulator/elite-accumulator-discharge-animation.png",
      width = 294,
      height = 256,
      line_length = 6,
      scale  = 0.5,	frame_count = 24,
      shift = {0.395, -0.525},
      animation_speed = 0.5
    },
    discharge_cooldown = 60,
    discharge_light = {intensity = 0.7, size = 7},
    working_sound =
    {
      sound =
      {
        filename = "__base__/sound/accumulator-working.ogg",
        volume = 1
      },
      idle_sound = {
        filename = "__base__/sound/accumulator-idle.ogg",
        volume = 0.4
      },
      max_sounds_per_type = 5
    },
  }
}
)
And here is the WaiTex overwrite code:

Code: Select all

	--[[basic-accumulator]]--
	["__base__/graphics/entity/basic-accumulator/basic-accumulator.png"] = function(t)  OverrideSprite(t[#t]) end,
	["__base__/graphics/entity/basic-accumulator/basic-accumulator-charge-animation.png"] = function(t)
		t[#t].layers = 
		{
			{
				width = 124 * 2,
				height = 103 * 2,
				frame_count = 24,
				shift = {0.7, -0.2},
				animation_speed = 0.5,
				scale = 0.5,
				stripes = (function()
					result = {}
					stripe = 
					{
						filename = "__WaiTex__/graphics/entity/basic-accumulator/basic-accumulator.png",
						width_in_frames = 1,
						height_in_frames = 1
					}
					for i = 1,24 do
						result[i] = stripe
					end
					return result
				end)()
			},
			{
				filename = "__WaiTex__/graphics/entity/basic-accumulator/basic-accumulator-charge-sparks.png",
				width = 138 * 2,
				height = 135  *2,
				line_length = 6,
				frame_count = 24,
				scale = 0.5,
				shift = {0.482, -0.638},
				animation_speed = 0.5
			}
		}
	end,
	["__base__/graphics/entity/basic-accumulator/basic-accumulator-discharge-animation.png"] = function(t)
		t[#t].layers = 
		{
			{
				width = 124 * 2,
				height = 103 * 2,
				frame_count = 24,
				shift = {0.7, -0.2},
				animation_speed = 0.5,
				scale = 0.5,
				stripes = (function()
					result = {}
					stripe = 
					{
						filename = "__WaiTex__/graphics/entity/basic-accumulator/basic-accumulator.png",
						width_in_frames = 1,
						height_in_frames = 1
					}
					for i = 1,24 do
						result[i] = stripe
					end
					return result
				end)()
			},
			{
				filename = "__WaiTex__/graphics/entity/basic-accumulator/basic-accumulator-discharge-sparks.png",
				width = 147 * 2,
				height = 128 * 2,
				line_length = 6,
				frame_count = 24,
				scale = 0.5,
				shift = {0.395, -0.525},
				animation_speed = 0.5
			}
		}
	end,
I have next to no coding knowledge and my attempts to make this work have failed. Any help would be appreciated!
User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: Combining WaiTex accumulator animation with another mod

Post by Arch666Angel »

Code: Select all

animation={
layers={
{layer1},
{layer2},
}
}
To get it to work right, name the layers accordingly, like 1name.png for the bottom layer, 2name.png for the overlay layer. The other method would be (which most base game buildings use) that the base sprite is "static" and the animation gets added as a working_visualisation
Dahak
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri Apr 29, 2016 9:19 pm
Contact:

Re: Combining WaiTex accumulator animation with another mod

Post by Dahak »

Well drat then. I already tried that but I must have messed up somewhere because it broke on load.

I tried tiling it as well, but I was trying to place the static mesh on the charge anim, which ended up really jittery even though I used a grid to place the images. I guess I could try to do it the other way around if I can find a way to tile it uniformly in GIMP (I hate GIMP, but it is free and photoshop not so much.)

What I did as a general workaround was to put lights on the accumulators similar to the chain signals to indicate what they are doing. I found the visual of that more immersive than the crazy arcing everywhere. If your power station is doing that you have a serious problem!
Post Reply

Return to “Modding help”