Page 1 of 1

[SOLVED] electric-energy-interface animations not working?

Posted: Sat Mar 24, 2018 2:22 am
by i.am.qix
I have an electric-energy-interface entity that I'm writing that has a three layer animation, but the animation is stuck at the first frame.

Here is the spec:

Code: Select all

data:extend{{
	type = 'electric-energy-interface',
	name = 'hand-crank',
	icon = '__base__/graphics/icons/accumulator.png',
	icon_size = 32,
	flags = {'placeable-neutral', 'player-creation'},
	minable = {hardness = 0.1, mining_time = 0.2, result = 'hand-crank'},
	max_health = 40,
	corpse = 'small-remnants',
	collision_box = {{-0.78, -0.62}, {0.77, 0.48}},
	selection_box = {{-0.78, -0.62}, {0.77, 0.48}},
	enable_gui = true,
	allow_copy_paste = false,
	energy_source =
	{
		type = 'electric',
		usage_priority = 'primary-output',
		render_no_power_icon = false,
		render_no_network_icon = true,
		buffer_capacity = '10kW',
		input_flow_limit = '0kW',
		output_flow_limit = '10kW'
	},
	energy_production = '0kW',
	energy_usage = "0kW",
	animation =
	{
		layers =
		{
			{
				filename = '__HandCrank__/graphics/entity/hand-crank.png',
				priority = 'extra-high',
				width = 96,
				height = 48,
				shift = {0.6, 0},
				line_length = 0,
				frame_count = 8,
				animation_speed = 0.2,
				run_mode = 'forward'
			},
			{
				filename = '__HandCrank__/graphics/entity/hand-crank_dark.png',
				priority = 'extra-high',
				width = 96,
				height = 48,
				shift = {0.6, 0},
				frame_count = 8,
				line_length = 0,
				animation_speed = 0.2,
				draw_as_shadow = true,
				run_mode = 'forward'
			},
			{
				filename = '__HandCrank__/graphics/entity/hand-crank_shadow.png',
				priority = 'extra-high',
				width = 96,
				height = 48,
				shift = {0.6, 0},
				line_length = 0,
				frame_count = 8,
				animation_speed = 0.2,
				run_mode = 'forward'
			}
		}
	},
	vehicle_impact_sound = {
		filename = '__base__/sound/car-metal-impact.ogg',
		volume = 0.4
	}
}}
Am I missing something? The sprite itself is PNG with the 8 frames appended horizontally, and as far as the loading goes the game is perfectly happy with how it's spec'd out. But the animation just doesn't want to run.

Any help?

EDIT: This happens even without layers (specifying the first layer as the top-level table keys).

Re: electric-energy-interface animations not working?

Posted: Sat Mar 24, 2018 2:42 am
by i.am.qix
Aha, never mind. Turns out the animation runs based on the current value of power_production. I needed to turn my animation speed wayyyy down to around 0.004 (!!!) in order to get it to work and look nice.

It was doing the animation fine, but it was going so ridiculously fast that it looked stationary.

For anyone that finds this in the future, you can debug your animations by enabling the entity's GUI, clicking on it and playing with the sliders. That's how I figured out my mistake :)

Re: [SOLVED] electric-energy-interface animations not working?

Posted: Sat Mar 24, 2018 2:20 pm
by eradicator
Just out of eer...let's call it "curiosity", what does your mod do that mine doesn't?

HandCrankGenerator

Re: [SOLVED] electric-energy-interface animations not working?

Posted: Sat Mar 24, 2018 2:23 pm
by i.am.qix
Nothing. :) I wasn't aware there was already a hand crank mod until shortly before I released.

Re: [SOLVED] electric-energy-interface animations not working?

Posted: Sat Mar 24, 2018 2:31 pm
by eradicator
i.am.qix wrote:Nothing. :) I wasn't aware there was already a hand crank mod until shortly before I released.
I see.

Re: [SOLVED] electric-energy-interface animations not working?

Posted: Sat Mar 24, 2018 2:44 pm
by i.am.qix
Is there a problem? O.o