How do I animate a texture?

Place to post guides, observations, things related to modding that are not mods themselves.
rainawareness
Inserter
Inserter
Posts: 22
Joined: Sat May 14, 2022 12:07 am
Contact:

Re: How do I animate a texture?

Post by rainawareness »

FuryoftheStars wrote:
Sat May 14, 2022 11:43 pm
You should use the code tags to preserve the indents (makes it easier to read :) ), or just attach the original file (which, btw, all those pics you uploaded to another site then linked to? You could've just attached them directly to your post. :) ).
code

That said, line 30 looks wrong to me:

Code: Select all

robot_animations.logistic_robot =
Maybe try changing it to:

Code: Select all

robot_animations = {
    logistic_robot =

    'other code

}
?

But this is a syntax error. These can be... misleading, depending on the issue. Actually giving a data type the wrong information it can be more precise on.
Oooh, thank you very much. In did a lot of the tab thing to make it better, and changed the robot_animations.logistic_robot thing:

Code: Select all

return {
	resource_pack_name = "vivillon_bots",



	data = {
		
		base = {
			prototypes= {
				entity = {
					["flying-robot.lua"] = {
						robot_animations = {
								logistic_robot = {
	 								idle =  {
									filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
									priority = "high",
									line_length = 2,
									width = 28,
									height = 36,
									frame_count = 2,
									shift = util.by_pixel(-0.25, -5),
									direction_count = 16,
									animation_speed = 0.3,
  								},

  							idle_with_cargo =  {
	    						filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
							priority = "high",
							line_length = 2,
							width = 28,
							height = 36,
							frame_count = 2,
							shift = util.by_pixel(-0.25, -5),
							direction_count = 16,
							animation_speed = 0.3,
  						},
  							in_motion =  {
	    						filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
							priority = "high",
							line_length = 2,
							width = 28,
							height = 36,
							frame_count = 2,
							shift = util.by_pixel(-0.25, -5),
							direction_count = 16,
							animation_speed = 0.3,
  						},
  							in_motion_with_cargo =  {
	    						filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
							priority = "high",
							line_length = 2,
							width = 28,
							height = 36,
							frame_count = 2,
							shift = util.by_pixel(-0.25, -5),
							direction_count = 16,
							animation_speed = 0.3,
  						},
				},	


						robots =
						{

						  	{
    							type = "logistic-robot",
    							name = "logistic-robot",
    							icon = "__base__/graphics/icons/logistic-robot.png",
    							icon_size = 64, icon_mipmaps = 4,
    							flags = {"placeable-player", "player-creation", "placeable-off-grid", "not-on-map"},
    							minable = {mining_time = 0.1, result = "logistic-robot"},

				
  							  idle = robot_animations.logistic_robot.idle,
  							  idle_with_cargo = robot_animations.logistic_robot.idle_with_cargo,
  							  in_motion = robot_animations.logistic_robot.in_motion,
  							  in_motion_with_cargo = robot_animations.logistic_robot.in_motion_with_cargo,
  							  shadow_idle = robot_animations.logistic_robot.shadow_idle,
  							  shadow_idle_with_cargo = robot_animations.logistic_robot.shadow_idle_with_cargo,
  							  shadow_in_motion = robot_animations.logistic_robot.shadow_in_motion,
  							  shadow_in_motion_with_cargo = robot_animations.logistic_robot.shadow_in_motion_with_cargo
  							},

						},

					},
				},
			},
		},
	},

	


	data = {
		
		base = {
			graphics = {
				entity = {
					["logistic-robot"] = {
						["logistic-robot.png"] = { },
						["hr-logistic-robot.png"] = { },
						
					},
				},
			},
		},
	


		

}
Which gives me this error: Image

So I removed the word "local". And now I get this which looks like the same vague error from earlier: Image

Thank you very much for your help. I just copied both times flying-robots.lua defined their animations, hoping it would work.

rainawareness
Inserter
Inserter
Posts: 22
Joined: Sat May 14, 2022 12:07 am
Contact:

Re: How do I animate a texture?

Post by rainawareness »

FuryoftheStars wrote:
Sat May 14, 2022 11:43 pm
You should use the code tags to preserve the indents (makes it easier to read :) ), or just attach the original file (which, btw, all those pics you uploaded to another site then linked to? You could've just attached them directly to your post. :) ).
code

That said, line 30 looks wrong to me:

Code: Select all

robot_animations.logistic_robot =
Maybe try changing it to:

Code: Select all

robot_animations = {
    logistic_robot =

    'other code

}
?

But this is a syntax error. These can be... misleading, depending on the issue. Actually giving a data type the wrong information it can be more precise on.

I added two right brackets to make it look like this:

Code: Select all

return {
	resource_pack_name = "vivillon_bots",



	data = {
		
		base = {
			prototypes= {
				entity = {
					["flying-robot.lua"] = {
						robot_animations = {
								logistic_robot = {
	 								idle =  {
									filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
									priority = "high",
									line_length = 2,
									width = 28,
									height = 36,
									frame_count = 2,
									shift = util.by_pixel(-0.25, -5),
									direction_count = 16,
									animation_speed = 0.3,
  								},

  							idle_with_cargo =  {
	    						filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
							priority = "high",
							line_length = 2,
							width = 28,
							height = 36,
							frame_count = 2,
							shift = util.by_pixel(-0.25, -5),
							direction_count = 16,
							animation_speed = 0.3,
  						},
  							in_motion =  {
	    						filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
							priority = "high",
							line_length = 2,
							width = 28,
							height = 36,
							frame_count = 2,
							shift = util.by_pixel(-0.25, -5),
							direction_count = 16,
							animation_speed = 0.3,
  						},
  							in_motion_with_cargo =  {
	    						filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
							priority = "high",
							line_length = 2,
							width = 28,
							height = 36,
							frame_count = 2,
							shift = util.by_pixel(-0.25, -5),
							direction_count = 16,
							animation_speed = 0.3,
  						},
				},	
				},
},


						robots =
						{

						  	{
    							type = "logistic-robot",
    							name = "logistic-robot",
    							icon = "__base__/graphics/icons/logistic-robot.png",
    							icon_size = 64, icon_mipmaps = 4,
    							flags = {"placeable-player", "player-creation", "placeable-off-grid", "not-on-map"},
    							minable = {mining_time = 0.1, result = "logistic-robot"},

				
  							  idle = robot_animations.logistic_robot.idle,
  							  idle_with_cargo = robot_animations.logistic_robot.idle_with_cargo,
  							  in_motion = robot_animations.logistic_robot.in_motion,
  							  in_motion_with_cargo = robot_animations.logistic_robot.in_motion_with_cargo,
  							  shadow_idle = robot_animations.logistic_robot.shadow_idle,
  							  shadow_idle_with_cargo = robot_animations.logistic_robot.shadow_idle_with_cargo,
  							  shadow_in_motion = robot_animations.logistic_robot.shadow_in_motion,
  							  shadow_in_motion_with_cargo = robot_animations.logistic_robot.shadow_in_motion_with_cargo
  							},

						},

					},
				},
			},
		},
	},

	


	data = {
		
		base = {
			graphics = {
				entity = {
					["logistic-robot"] = {
						["logistic-robot.png"] = { },
						["hr-logistic-robot.png"] = { },
						
					},
				},
			},
		},
	


		

}
And now it gives me this error which sounds totally different: Image
Do you know what that could mean???

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2485
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: How do I animate a texture?

Post by FuryoftheStars »

Move the bracket from line 92 to line 110.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

rainawareness
Inserter
Inserter
Posts: 22
Joined: Sat May 14, 2022 12:07 am
Contact:

Re: How do I animate a texture?

Post by rainawareness »

FuryoftheStars wrote:
Sun May 15, 2022 12:30 am
Move the bracket from line 92 to line 110.
I think there's no longer a bracket problem:

Code: Select all

return {
	resource_pack_name = "vivillon_bots",



	data = {
		
		base = {
			prototypes= {
				entity = {
					["flying-robot.lua"] = {
						robot_animations = {
								logistic_robot = {
	 								idle =  {
									filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
									priority = "high",
									line_length = 2,
									width = 28,
									height = 36,
									frame_count = 2,
									shift = util.by_pixel(-0.25, -5),
									direction_count = 16,
									animation_speed = 0.3,
  								},

  							idle_with_cargo =  {
	    						filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
							priority = "high",
							line_length = 2,
							width = 28,
							height = 36,
							frame_count = 2,
							shift = util.by_pixel(-0.25, -5),
							direction_count = 16,
							animation_speed = 0.3,
  						},
  							in_motion =  {
	    						filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
							priority = "high",
							line_length = 2,
							width = 28,
							height = 36,
							frame_count = 2,
							shift = util.by_pixel(-0.25, -5),
							direction_count = 16,
							animation_speed = 0.3,
  						},
  							in_motion_with_cargo =  {
	    						filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
							priority = "high",
							line_length = 2,
							width = 28,
							height = 36,
							frame_count = 2,
							shift = util.by_pixel(-0.25, -5),
							direction_count = 16,
							animation_speed = 0.3,
  						},
				},	
				},
},


						robots =
						{

						  	{
    							type = "logistic-robot",
    							name = "logistic-robot",
    							icon = "__base__/graphics/icons/logistic-robot.png",
    							icon_size = 64, icon_mipmaps = 4,
    							flags = {"placeable-player", "player-creation", "placeable-off-grid", "not-on-map"},
    							minable = {mining_time = 0.1, result = "logistic-robot"},

				
  							  idle = robot_animations.logistic_robot.idle,
  							  idle_with_cargo = robot_animations.logistic_robot.idle_with_cargo,
  							  in_motion = robot_animations.logistic_robot.in_motion,
  							  in_motion_with_cargo = robot_animations.logistic_robot.in_motion_with_cargo,
  							  shadow_idle = robot_animations.logistic_robot.shadow_idle,
  							  shadow_idle_with_cargo = robot_animations.logistic_robot.shadow_idle_with_cargo,
  							  shadow_in_motion = robot_animations.logistic_robot.shadow_in_motion,
  							  shadow_in_motion_with_cargo = robot_animations.logistic_robot.shadow_in_motion_with_cargo
  							},

						},

					},
				},
			},
		
	},

	


	data = {
		
		base = {
			graphics = {
				entity = {
					["logistic-robot"] = {
						["logistic-robot.png"] = { },
						["hr-logistic-robot.png"] = { },
						
					},
				},
			},
		}, },
	

	

}
However, not there's a robot_animations is a nil value error: Image
Changing that part back to ["robot_animations.logistic_robot"] = { got the same error. Does this mean I can't just rewrite part of flying-robots.lua after all?

Thank you very much, I wouldn't have gotten this close without all of your help.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2485
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: How do I animate a texture?

Post by FuryoftheStars »

Ok, let's look at this differently. You're just trying to change some properties to the existing robots, right? Not create all new ones?

Personally, I'd put my code directly into the data-final-fixes.lua file, rather than using it to call another file, but I'd also approach it like this:

Code: Select all

local logistic_robot = data.raw["logistic-robot"]["logistic-robot"]
logistic_robot.idle = 
{
    filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
    priority = "high",
    line_length = 16,
    width = 41,
    height = 42,
    frame_count = 1,
    shift = util.by_pixel(0, -3),
    direction_count = 16,
    y = 42,
    hr_version =
    {
        filename = "__base__/graphics/entity/logistic-robot/hr-logistic-robot.png",
        priority = "high",
        line_length = 16,
        width = 80,
        height = 84,
        frame_count = 1,
        shift = util.by_pixel(0, -3),
        direction_count = 16,
        y = 84,
        scale = 0.5
    }
}
And make the appropriate changes. Then do this for each animation you need to work with, and similarly for the logistic construction bots.

Edit: Sorry, forgot you were working on the logistic bot. Updated code.
And yes, robot_animations.logistic_robot doesn't actually exist within the actual logistic-robot entity because that's just a pointer to the actual data. Why they did it like this I'm not sure. Maybe they were planning on other types of logistic bots at one point? As it's only used in the logistic bots themselves, there was no need for the extra storing of the data into the robot_animations.logistic_robot variable.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

rainawareness
Inserter
Inserter
Posts: 22
Joined: Sat May 14, 2022 12:07 am
Contact:

Re: How do I animate a texture?

Post by rainawareness »

FuryoftheStars wrote:
Sun May 15, 2022 1:25 am
Ok, let's look at this differently. You're just trying to change some properties to the existing robots, right? Not create all new ones?

Personally, I'd put my code directly into the data-final-fixes.lua file, rather than using it to call another file, but I'd also approach it like this:

Code: Select all

local logistic_robot = data.raw["logistic-robot"]["logistic-robot"]
logistic_robot.idle = 
{
    filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
    priority = "high",
    line_length = 16,
    width = 41,
    height = 42,
    frame_count = 1,
    shift = util.by_pixel(0, -3),
    direction_count = 16,
    y = 42,
    hr_version =
    {
        filename = "__base__/graphics/entity/logistic-robot/hr-logistic-robot.png",
        priority = "high",
        line_length = 16,
        width = 80,
        height = 84,
        frame_count = 1,
        shift = util.by_pixel(0, -3),
        direction_count = 16,
        y = 84,
        scale = 0.5
    }
}
And make the appropriate changes. Then do this for each animation you need to work with, and similarly for the logistic construction bots.

Edit: Sorry, forgot you were working on the logistic bot. Updated code.
And yes, robot_animations.logistic_robot doesn't actually exist within the actual logistic-robot entity because that's just a pointer to the actual data. Why they did it like this I'm not sure. Maybe they were planning on other types of logistic bots at one point? As it's only used in the logistic bots themselves, there was no need for the extra storing of the data into the robot_animations.logistic_robot variable.
I thought I was editing the existing bots, but whatever lets me animate them is fine.
There are no weird errors anymore! Thank you very much for your code and your idea and your patience. You even found some kind of coding oversight!
I edited the code to make it so all 4 logistic bot stances get "drawn" in the same shape as construction bot's working stance:

Code: Select all

local logistic_robot = data.raw["logistic-robot"]["logistic-robot"]
logistic_robot.idle = 
{
    filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
    priority = "high",
    line_length = 2,
    width = 28,
    height = 36,
    frame_count = 2,
    shift = util.by_pixel(-0.25, -5),
    direction_count = 16,
    animation_speed = 0.3,
    hr_version =
    {
        filename = "__base__/graphics/entity/logistic-robot/hr-logistic-robot.png",
        priority = "high",
        line_length = 16,
        width = 57,
        height = 74,
        frame_count = 2,
        shift = util.by_pixel(-0.25, -5),
        direction_count = 16,
        animation_speed = 0.3,
        scale = 0.5
    }



}

logistic_robot.idle_withcargo = 
{
    filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
    priority = "high",
    line_length = 2,
    width = 28,
    height = 36,
    frame_count = 2,
    shift = util.by_pixel(-0.25, -5),
    direction_count = 16,
    animation_speed = 0.3,
    hr_version =
    {
        filename = "__base__/graphics/entity/logistic-robot/hr-logistic-robot.png",
        priority = "high",
        line_length = 16,
        width = 57,
        height = 74,
        frame_count = 2,
        shift = util.by_pixel(-0.25, -5),
        direction_count = 16,
        animation_speed = 0.3,
        scale = 0.5
    }



}

logistic_robot.in_motion = 
{
    filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
    priority = "high",
    line_length = 2,
    width = 28,
    height = 36,
    frame_count = 2,
    shift = util.by_pixel(-0.25, -5),
    direction_count = 16,
    animation_speed = 0.3,
    hr_version =
    {
        filename = "__base__/graphics/entity/logistic-robot/hr-logistic-robot.png",
        priority = "high",
        line_length = 16,
        width = 57,
        height = 74,
        frame_count = 2,
        shift = util.by_pixel(-0.25, -5),
        direction_count = 16,
        animation_speed = 0.3,
        scale = 0.5
    }



}

logistic_robot.in_motion_with_cargo = 
{
    filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
    priority = "high",
    line_length = 2,
    width = 28,
    height = 36,
    frame_count = 2,
    shift = util.by_pixel(-0.25, -5),
    direction_count = 16,
    animation_speed = 0.3,
    hr_version =
    {
        filename = "__base__/graphics/entity/logistic-robot/hr-logistic-robot.png",
        priority = "high",
        line_length = 16,
        width = 57,
        height = 74,
        frame_count = 2,
        shift = util.by_pixel(-0.25, -5),
        direction_count = 16,
        animation_speed = 0.3,
        scale = 0.5
    }



}
Now I get this error, which says the sprite size isn't what it should be:
Image
Which is kinda weird and impossible, because I replaced that image with the construction bots' working spritesheet to test it out. Which obviously is of the exact same expected dimensions.

If you by any chance know if this means sprite size wasn't changed after all, or there's something wrong with the image or what it is or what I can do; please please let me know!
Thanks again for all of your help.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2485
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: How do I animate a texture?

Post by FuryoftheStars »

Off hand what I'm seeing is that you've changed all of the values related to the sprite sheet, but are still using the same sprite sheet.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

rainawareness
Inserter
Inserter
Posts: 22
Joined: Sat May 14, 2022 12:07 am
Contact:

Re: How do I animate a texture?

Post by rainawareness »

FuryoftheStars wrote:
Sun May 15, 2022 3:46 am
Off hand what I'm seeing is that you've changed all of the values related to the sprite sheet, but are still using the same sprite sheet.
Whaaat? Nono, the sprite sheets have been changed. They were changed to the construction robot's "working" sprite sheet, which is why I changed the values to the "working" values:
Image
Or I'm misunderstanding what you said. I tried seeing if there was something somewhere that messed up the sprite size, because the error says the size is 56x576. Which would look like this: https://i.imgur.com/y5E8tAq.png

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2485
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: How do I animate a texture?

Post by FuryoftheStars »

Hmm, the code you posted still shows the filename pointing to the original base files?
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: How do I animate a texture?

Post by Bilka »

See viewtopic.php?p=343228#p343228 (old, but may still apply).
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

rainawareness
Inserter
Inserter
Posts: 22
Joined: Sat May 14, 2022 12:07 am
Contact:

Re: How do I animate a texture?

Post by rainawareness »

Bilka wrote:
Sun May 15, 2022 7:29 am
See viewtopic.php?p=343228#p343228 (old, but may still apply).
Oh no, oh no!!! Well I think I replied to that post to see if that is still the case, thank you very much.

rainawareness
Inserter
Inserter
Posts: 22
Joined: Sat May 14, 2022 12:07 am
Contact:

Re: How do I animate a texture?

Post by rainawareness »

FuryoftheStars wrote:
Sun May 15, 2022 4:29 am
Hmm, the code you posted still shows the filename pointing to the original base files?
Well that was the way I had been able to change textures which worked, have some text in the config filed and mirror the file tree:

Code: Select all

return {
	resource_pack_name = "vivillon_bots",



	data = {
		
		base = {
			graphics = {
				entity = {
					["logistic-robot"] = {
						["logistic-robot.png"] = { },
						["hr-logistic-robot.png"] = { },
						
					},
				},
			},
		}, 
	},
	


}
But that was before I had even opened data-final-fixes, do you perhaps know how I should go about that now? Thank you.

rainawareness
Inserter
Inserter
Posts: 22
Joined: Sat May 14, 2022 12:07 am
Contact:

Re: How do I animate a texture?

Post by rainawareness »

FuryoftheStars wrote:
Sun May 15, 2022 1:25 am
Ok, let's look at this differently. You're just trying to change some properties to the existing robots, right? Not create all new ones?

Personally, I'd put my code directly into the data-final-fixes.lua file, rather than using it to call another file, but I'd also approach it like this:

Code: Select all

local logistic_robot = data.raw["logistic-robot"]["logistic-robot"]
logistic_robot.idle = 
{
    filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
    priority = "high",
    line_length = 16,
    width = 41,
    height = 42,
    frame_count = 1,
    shift = util.by_pixel(0, -3),
    direction_count = 16,
    y = 42,
    hr_version =
    {
        filename = "__base__/graphics/entity/logistic-robot/hr-logistic-robot.png",
        priority = "high",
        line_length = 16,
        width = 80,
        height = 84,
        frame_count = 1,
        shift = util.by_pixel(0, -3),
        direction_count = 16,
        y = 84,
        scale = 0.5
    }
}
And make the appropriate changes. Then do this for each animation you need to work with, and similarly for the logistic construction bots.

Edit: Sorry, forgot you were working on the logistic bot. Updated code.
And yes, robot_animations.logistic_robot doesn't actually exist within the actual logistic-robot entity because that's just a pointer to the actual data. Why they did it like this I'm not sure. Maybe they were planning on other types of logistic bots at one point? As it's only used in the logistic bots themselves, there was no need for the extra storing of the data into the robot_animations.logistic_robot variable.
Ok turns out your code was perfect and it worked. Problem is that it doesn't animate, but just in the nick of time I got this comment to a link from 2018 saying animating idle states IS NOT SUPPORTED. NOT SUPPORTED. viewtopic.php?f=28&t=57723&p=568079#p568079
I'm so sorry, I had no idea such a thing could have been the case. Thank you very much for all of your help and patience, and sorry that because of my ignorance it ended up being for nothing in the end.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2485
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: How do I animate a texture?

Post by FuryoftheStars »

rainawareness wrote:
Sun May 15, 2022 2:14 pm
FuryoftheStars wrote:
Sun May 15, 2022 4:29 am
Hmm, the code you posted still shows the filename pointing to the original base files?
Well that was the way I had been able to change textures which worked, have some text in the config filed and mirror the file tree:

[...]

But that was before I had even opened data-final-fixes, do you perhaps know how I should go about that now? Thank you.
If you're going to change the properties related to the animation frames, you should give it a new (and appropriate) sprite sheet to look at, otherwise it's trying to take your new values and match them up to an old sheet and will (potentially) run into issues. You should create a new sprite sheet of the correct dimensions you're referencing and put it in your mod, then change the filename to point to it.

I'm certainly no expert on the animations in this game, though. While I have studied it some in the past, I've only in the past couple of weeks actually started delving into it for a redux of a someone else's mod I'm working on.

Here's the prototype code for an entity in that mod that I'm adding animations to. Note that it's a new entity, so I need to add it later with data:extend, and that it's animation is actually only added if the user selects a certain startup setting:

Code: Select all

local planter =
{
    type = "assembling-machine",
    name = "planter",
    flags = {"placeable-neutral", "player-creation"},
    icon = "__TreeSaplings-Redux__/graphics/icons/planter.png",
    icon_size = 32,
    max_health = 100,
    minable =
    {
        mining_time = 1,
        result = "planter"
    },
    corpse = "small-remnants",
    collision_box = {{-0.75, -0.75}, {0.75, 0.75}},
    selection_box = {{-1.0, -1.0}, {1.0, 1.0}},
    energy_usage = "1W",
    energy_source =
    {
        type = "void"
    },
    fixed_recipe= "grow-sapling",
    show_recipe_icon = false,
    crafting_categories = {"growing"},
    crafting_speed = 1,
    ingredient_count = 1,
    vehicle_impact_sound = {filename = "__base__/sound/car-wood-impact.ogg", volume = 1.0},
    animation =
    {
        layers =
        {
            {
                filename = "__TreeSaplings-Redux__/graphics/entities/planter/planter.png",
                priority = "extra-high",
                width = 64,
                height = 64,
                frame_count = 1,
                shift = {0.00, 0.00}
            }
        }
    }
}

if globalvalues.ups_friendly then
    planter.drawing_box = {{-0.5, -2.25},{0.5, 0.6}}
    planter.energy_source.emissions_per_minute = sapling.emissions_per_second * 60 * (globalvalues.frames_with_sapling / globalvalues.planter_animation_frame_count)
    planter.working_visualisations = 
    {
        {
            effect = "none",
            animation =
            {
                layers =
                {
                    {
                        filename = "__TreeSaplings-Redux__/graphics/entities/planter/sapling-a-trunk.png",
                        priority = "extra-high",
                        width = 67,
                        height = 161,
                        scale = 0.5,
                        frame_count = globalvalues.planter_animation_frame_count,
                        shift = {0, -0.9},
                        animation_speed = globalvalues.planter_animation_speed
                    },
                    {
                        filename = "__TreeSaplings-Redux__/graphics/entities/planter/sapling-a-leaves.png",
                        priority = "extra-high",
                        width = 97,
                        height = 109,
                        scale = 0.5,
                        frame_count = globalvalues.planter_animation_frame_count,
                        shift = {0.015625, -1.603125},
                        animation_speed = globalvalues.planter_animation_speed
                    }
                }
            }
        }
    }
end
All "globalvalues" are defined elsewhere as well.

Edit:
rainawareness wrote:
Sun May 15, 2022 2:52 pm
Ok turns out your code was perfect and it worked. Problem is that it doesn't animate, but just in the nick of time I got this comment to a link from 2018 saying animating idle states IS NOT SUPPORTED. NOT SUPPORTED. viewtopic.php?f=28&t=57723&p=568079#p568079
I'm so sorry, I had no idea such a thing could have been the case. Thank you very much for all of your help and patience, and sorry that because of my ignorance it ended up being for nothing in the end.
Ah, understood. That could be the issue in your case.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

rainawareness
Inserter
Inserter
Posts: 22
Joined: Sat May 14, 2022 12:07 am
Contact:

Re: How do I animate a texture?

Post by rainawareness »

FuryoftheStars wrote:
Sun May 15, 2022 2:54 pm
rainawareness wrote:
Sun May 15, 2022 2:14 pm
FuryoftheStars wrote:
Sun May 15, 2022 4:29 am
Hmm, the code you posted still shows the filename pointing to the original base files?
Well that was the way I had been able to change textures which worked, have some text in the config filed and mirror the file tree:

[...]

But that was before I had even opened data-final-fixes, do you perhaps know how I should go about that now? Thank you.
If you're going to change the properties related to the animation frames, you should give it a new (and appropriate) sprite sheet to look at, otherwise it's trying to take your new values and match them up to an old sheet and will (potentially) run into issues. You should create a new sprite sheet of the correct dimensions you're referencing and put it in your mod, then change the filename to point to it.

I'm certainly no expert on the animations in this game, though. While I have studied it some in the past, I've only in the past couple of weeks actually started delving into it for a redux of a someone else's mod I'm working on.

Here's the prototype code for an entity in that mod that I'm adding animations to. Note that it's a new entity, so I need to add it later with data:extend, and that it's animation is actually only added if the user selects a certain startup setting:

Code: Select all

local planter =
{
    type = "assembling-machine",
    name = "planter",
    flags = {"placeable-neutral", "player-creation"},
    icon = "__TreeSaplings-Redux__/graphics/icons/planter.png",
    icon_size = 32,
    max_health = 100,
    minable =
    {
        mining_time = 1,
        result = "planter"
    },
    corpse = "small-remnants",
    collision_box = {{-0.75, -0.75}, {0.75, 0.75}},
    selection_box = {{-1.0, -1.0}, {1.0, 1.0}},
    energy_usage = "1W",
    energy_source =
    {
        type = "void"
    },
    fixed_recipe= "grow-sapling",
    show_recipe_icon = false,
    crafting_categories = {"growing"},
    crafting_speed = 1,
    ingredient_count = 1,
    vehicle_impact_sound = {filename = "__base__/sound/car-wood-impact.ogg", volume = 1.0},
    animation =
    {
        layers =
        {
            {
                filename = "__TreeSaplings-Redux__/graphics/entities/planter/planter.png",
                priority = "extra-high",
                width = 64,
                height = 64,
                frame_count = 1,
                shift = {0.00, 0.00}
            }
        }
    }
}

if globalvalues.ups_friendly then
    planter.drawing_box = {{-0.5, -2.25},{0.5, 0.6}}
    planter.energy_source.emissions_per_minute = sapling.emissions_per_second * 60 * (globalvalues.frames_with_sapling / globalvalues.planter_animation_frame_count)
    planter.working_visualisations = 
    {
        {
            effect = "none",
            animation =
            {
                layers =
                {
                    {
                        filename = "__TreeSaplings-Redux__/graphics/entities/planter/sapling-a-trunk.png",
                        priority = "extra-high",
                        width = 67,
                        height = 161,
                        scale = 0.5,
                        frame_count = globalvalues.planter_animation_frame_count,
                        shift = {0, -0.9},
                        animation_speed = globalvalues.planter_animation_speed
                    },
                    {
                        filename = "__TreeSaplings-Redux__/graphics/entities/planter/sapling-a-leaves.png",
                        priority = "extra-high",
                        width = 97,
                        height = 109,
                        scale = 0.5,
                        frame_count = globalvalues.planter_animation_frame_count,
                        shift = {0.015625, -1.603125},
                        animation_speed = globalvalues.planter_animation_speed
                    }
                }
            }
        }
    }
end
All "globalvalues" are defined elsewhere as well.

Edit:
rainawareness wrote:
Sun May 15, 2022 2:52 pm
Ok turns out your code was perfect and it worked. Problem is that it doesn't animate, but just in the nick of time I got this comment to a link from 2018 saying animating idle states IS NOT SUPPORTED. NOT SUPPORTED. viewtopic.php?f=28&t=57723&p=568079#p568079
I'm so sorry, I had no idea such a thing could have been the case. Thank you very much for all of your help and patience, and sorry that because of my ignorance it ended up being for nothing in the end.
Ah, understood. That could be the issue in your case.
Thank you very much for your explanation and the code you provided. There wasn't any single animating explanation before this I could find, at least hopefully this thread will help someone in the future. I hope your own animation turns out great!

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: How do I animate a texture?

Post by Deadlock989 »

rainawareness wrote:
Sat May 14, 2022 5:10 pm
What I want to do is give logistic bots an idle animation, as in no matter where they are facing.
Unfortunately this is not possible. "Working" animations on flying bots can be animated, but idle and in_motion cannot. See viewtopic.php?f=58&t=71940
Image

Post Reply

Return to “Modding discussion”