Currently Online

Latest Posts

Topic: animation_directory not working with addons?

kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2182
Ranking
One Elder of Players
Location: Germany
Posted at: 2022-09-14, 18:44

I am trying to make a new add-on with some new immovables and whenever i try to use animation_directory = … the editor fails to start with this errormessage:

[00:00:01.702 real] ERROR:   FATAL EXCEPTION in editor: [/home/kaputtnik/Quellcode/widelands-repo/widelands/src/scripting/lua_errors.cc:21] Error loading animation 'idle' for map object 'hilltop_01': Animation in directory 'addons/hilltops.wad/world/hilltop_01/' with basename 'idle' has no images for mandatory scale '1' in mipmap - supported scales are: 0.5, 1, 2, 4
[00:00:01.702 real] ERROR: stack traceback:
[00:00:01.702 real] ERROR:      [string "addons/hilltops.wad/world/hilltop_01/init.lua..."]:5: in main chunk

The corresponding file looks like this:

push_textdomain("hilltops.wad", true)

local dirname = path.dirname(__file__)

wl.Descriptions():new_immovable_type{
   name = "hilltop_01",
   descname = _("Hilltop 1"),
   size = "big",
   programs = {},
   animation_directory = dirname,
   animations = {
      idle = {
         -- pictures = path.list_files(dirname .. "hilltop_01.png"),
         hotspot = { 18, 49 },
      },
   }
}

pop_textdomain()

Using the old (deprecated) syntax pictures = … works.

Or am i doing something wrong?


Wir sind alle nur chemische Marionetten,
hängen an Desoxyribonukleinsäureketten.

Jazzkantine - Alles nur Chemie

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1660
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2022-09-14, 20:56

Rename hilltop_01.png to idle_1.png – if you don't specify an animation basename, the image filenames must match the animation name.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2280
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2022-09-14, 20:59

from the code provided you want to use the PNG "hilltop_01.png" for the animation idle. so you need to specify the basename (basename = "hilltop") in the definition of the idle animation. maybe you need to rename hilltop_01 to hilltop_1 as the code expects images with the suffixes _0.5, _1, _2 and _4.


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2182
Ranking
One Elder of Players
Location: Germany
Posted at: 2022-09-15, 07:50

Oh yeah, thanks, that was the mistake.


Wir sind alle nur chemische Marionetten,
hängen an Desoxyribonukleinsäureketten.

Jazzkantine - Alles nur Chemie

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2182
Ranking
One Elder of Players
Location: Germany
Posted at: 2022-09-15, 08:48

Now i can't get an animation to work:

There are 4 files called idle_1.png to idle_4.png. Lua file:

push_textdomain("hilltops.wad", true)

local dirname = path.dirname(__file__)
wl.Descriptions():new_immovable_type{
   name = "waterfall",
   descname = _ "Waterfall",
   size = "big",
   programs = {},
   animation_directory = dirname,
   animations = {
      idle = {
         --pictures = path.list_files(dirname .. "waterfall_??.png"),
         hotspot = { 64, 88 },
         fps = 10,
      }
   }
}
pop_textdomain()

Error:

FATAL EXCEPTION in editor: [/home/kaputtnik/Quellcode/widelands-repo/widelands/src/scripting/lua_errors.cc:21] Error loading animation 'idle' for map object 'waterfall': Animation with one picture addons/hilltops.wad/world/waterfall//idle_4.png must not have 'fps'

Instead of fps = i have also tried to use "animate=idle duration:500ms" but with no success.


Wir sind alle nur chemische Marionetten,
hängen an Desoxyribonukleinsäureketten.

Jazzkantine - Alles nur Chemie

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2280
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2022-09-15, 10:17

it seems we still may have a misunderstanding here.

I thought you would like to use a still picture aniumation with only 1 file.

the suffixes _0.5 to _4 are referring to a scale and not a sequence and we only use file animations for single image anims. However if you want to use them you need to rename again ( I assume your sequence is all at scale 1) to idle_1_00.png to idle_1_03.png.

you may look at our test file at file animation test repo to get the full syntax.

But as file animations are kind of deprecated I strongly recommend to generate the proper spritesheet animation after you got the addon working. for this you might use the wl_create_spritesheets executable built with our website tools.
However you may just ask me or @tothxa for help with this.


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2182
Ranking
One Elder of Players
Location: Germany
Posted at: 2022-09-15, 18:12

hessenfarmer wrote:

it seems we still may have a misunderstanding here.

I thought you would like to use a still picture aniumation with only 1 file.

No, not a misunderstanding. There are some immovables with only one image and another which is animated.

the suffixes _0.5 to _4 are referring to a scale and not a sequence and we only use file animations for single image anims. However if you want to use them you need to rename again ( I assume your sequence is all at scale 1) to idle_1_00.png to idle_1_03.png.

Ahh face-smile.png Thanks a lot, now i got it to work.
Is this documented some where? Couldn't find such face-sad.png

you may look at our test file at file animation test repo to get the full syntax.

Maybe a wiki article "Addons Immovables" would be better than digging into the source code?

But as file animations are kind of deprecated I strongly recommend to generate the proper spritesheet animation after you got the addon working.

Yes, of course. After finishing the add-on.

Thanks again face-smile.png


Wir sind alle nur chemische Marionetten,
hängen an Desoxyribonukleinsäureketten.

Jazzkantine - Alles nur Chemie

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1660
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2022-09-15, 18:16

Documented in detail at https://www.widelands.org/documentation/animations/


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2280
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2022-09-15, 18:20

kaputtnik wrote:

Ahh face-smile.png Thanks a lot, now i got it to work.
Is this documented some where? Couldn't find such face-sad.png

see https://www.widelands.org/documentation/animations/#file-animations


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2182
Ranking
One Elder of Players
Location: Germany
Posted at: 2022-09-15, 18:45

I didn't read this because the relevant paragraph is below the deprecated parameter basename and i wanted to not use deprecated parameters, so i didn't read this chapter.


Wir sind alle nur chemische Marionetten,
hängen an Desoxyribonukleinsäureketten.

Jazzkantine - Alles nur Chemie

Top Quote