Latest Posts

Topic: Custom building, path to images

kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2551
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2020-08-20, 18:52

I have a custom building in a scenario. Currently this is just a another building as headquarter. Now i have tried to modify the image(s) and put them into the tribes directory of the maps scenario folder:

├── scripting
│   ├── helper_functions.lua
│   ├── init.lua
│   ├── objectives.lua
│   ├── starting_conditions.lua
│   ├── story_script.lua
│   ├── texts.lua
│   └── tribes
│       ├── init.lua
│       └── poseidon_hq
│           ├── helptexts.lua
│           ├── idle_00.png
│           ├── init.lua
│           ├── menu.png
│           └── register.lua

Now i have the problem that the image isn't found: Animation without image files. I have tried several possibilities:

dirname = "map:scripting/tribes/poseidon_hq/"

I guess this do not work because the map: variable isn't set on initialization of the tribes.

dirname = path.dirname(__file__)

This should work, at least it gives me the path scripting/tribes/poseidon_hq/ but the error remains.

Any hints to get the correct path/folder/dirname?

For completeness, here is the init.lua for this building:

tribes = wl.Tribes()
--dirname = "map:scripting/tribes/poseidon_hq/"
--dirname = "tribes/buildings/trainingsites/atlanteans/labyrinth/"
dirname = path.dirname(__file__)
print("Dirname", dirname)

tribes:new_warehouse_type {
   msgctxt = "atlanteans_building",
   name = "hq_poseidon",
   -- TRANSLATORS: This is a building name used in lists of buildings
   descname = pgettext("atlanteans_building", "Headquarters"),
   helptext_script = dirname .. "helptexts.lua",
   icon = dirname .. "menu.png",
   size = "big",
   destructible = false,
   --animation_directory = ""
   animations = {
      idle = {
         pictures = path.list_files(dirname .. "idle_??.png"),
              hotspot = { 80, 88 },
      },
   },

   aihints = {},

   heal_per_second = 220,
   conquers = 2,
}

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2745
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-08-20, 19:07

well first of all we need the exact commit of your branch as we are doing a lot of changes in this currently


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2745
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-08-20, 19:11

in b21 it shoul work to specify the path relative to the data dir (e.g. we have helptext_script = "campaigns/emp04.wmf/scripting/tribes/vesta_helptexts.lua", in a scenario building of emp04)


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2551
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2020-08-20, 19:54

I am as close as possible to the latest commit. This does not work with 1.0~git178[d13beaf@master]. Others i haven't testet so far.

hessenfarmer wrote:

in b21 it shoul work to specify the path relative to the data dir (e.g. we have helptext_script = "campaigns/emp04.wmf/scripting/tribes/vesta_helptexts.lua", in a scenario building of emp04)

This is a scenario map... not intended to be part of widelands (at least for now). So if i upload it to the website, i have no idea where the datadir of a foreign user is.

In Scnerio specific units it is mentioned:

You can also add helptexts.lua and .png files to your subdirectories.

I just can't fiddle out the correct path to the image(s).

Edit:
Or do have to store the image(s) in a separate folder, so that only images are in this folder?

Edited: 2020-08-20, 19:56

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2745
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-08-20, 20:39

well this is weird. as it should work. need to dig deeper but this can take a couple of hours.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2745
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-08-20, 22:30

I believe there is a bug see https://github.com/widelands/widelands/issues/4139


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 20:48
Posts: 2551
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2020-08-21, 08:06

Thanks face-smile.png


Top Quote