Animation lua code

Place to get help with not working mods / modding interface.
Post Reply
Vulcan
Inserter
Inserter
Posts: 48
Joined: Sat Aug 02, 2014 12:34 pm
Contact:

Animation lua code

Post by Vulcan »

What do the different sections of this block do? (East, south and west are omitted)
I am asking because the entity picture on my mod is wonky and I don't know what to change to fix it!
animation =
{
north =
{
filename = "__modName_/filepath/image.png",
frame_width = 337,
frame_height = 255,
frame_count = 1,
shift = {2.515625, 0.484375}
}
}
Also, what does working_visualisations do?

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Animation lua code

Post by FreeER »

Vulcan wrote:What do the different sections of this block do?
Well, assuming it's within an entity type that actually uses them (look in base/wiki), then I would assume that:
when the entity is rotated 'north', the 'north' animation would be used, when rotated 'east' the 'east' animation is used...
For knowing which way is "north" in game, you can test with the console (game.player.print(game.player.selected.direction), see data\core\lualib\defines.lua -> direction), or look at base graphics.

As for working_visualisations, it would appear that the direction_position(s) indicate the offset (from the center of the above animations) that the working_visualisations.animation should appear.
For instance, looking at the oil-refinery in the base game, the devs have actually used the same image for all four directions by defining 'x' inside the 'Sprite' definition for each direction to be the pixel offset of that sprite (excluding north, which would be an offset of 0). And with the working_visualisations.animation (which is obviously the flame), the working_visualisations.north_position indicates an offset of {1.03125, -1.55} or, 1.03125 tiles on the x axis (aka to the right), and -1.55 tiles on the y axis (aka up).

At least, i believe that would be correct...I've never done more than recolor the base images though so I've never really had to change any of those.

Vulcan
Inserter
Inserter
Posts: 48
Joined: Sat Aug 02, 2014 12:34 pm
Contact:

Re: Animation lua code

Post by Vulcan »

The code that I was asking about actually did come from the oil-refinery in base, and I was recolouring the oil refinery image and when I ran Factorio the image appeared below and to the right of the selection box, which is what I am trying to fix.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Animation lua code

Post by FreeER »

Vulcan wrote:the image appeared below and to the right of the selection box
in that case you should modify, or probably delete, the animation.shift value. In your code it is telling Factorio to 'shift' the center of the provided image 2.515625 tiles right, and 0.484375 down, after drawing the selection/collision box; the shift value, as far as I can tell, is for these relatively small adjustments to match the collision and selection boxes to the image itself.

Post Reply

Return to “Modding help”