Currently Online

Latest Posts

Topic: Tile replacement addon

atomikaya
Avatar
Topic Opener
Joined: 2022-12-22, 22:42
Posts: 7
OS: Fedora Linux
Version: 1.1
Ranking
Pry about Widelands
Posted at: 2023-01-29, 23:56

I'm playing around a world addon to replace the default tiles (not sure I'm going anywhere with this but it's a neat way to play around with the addon system and the art style).

I copied and adapted the code of the legacy_terrains addon which seemed to do exactly that. But the tiles don't show up, the usual ones appear instead.

To be more specific:

  • they don't show up when I start a new game
  • they appear in the editor menu when I create a new map, but the newly created map is still filled with the vanilla terrain
  • then if I try to create a new map a second time the vanilla tiles appear in the menu, suggesting something is getting overwritten somewhere

Is this a bug, or am I doing something wrong?

Sample content of my postload.lua file:

local D = wl.Descriptions()

D:modify_unit(
    "terrain",
    "desert_beach",
    "textures",
    { textures = path.list_files(path.dirname(__file__) .. "desert/beach.png" )}
)

-- …

The files are 64x64 pngs in the desert folder. I have copied over the editor.lua file and the addon file seems fine too. I'm a bit lost.


EDIT: I also checked what happened if I make the terrain tiles into indexed png but that's not it.

Edited: 2023-01-30, 00:12

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2057
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2023-01-30, 08:51

That the editor sometimes does not postload add-ons is a known bug which I'm working on.

In version 1.1, world add-ons have to be part of the map in order to use them, they are not applied when starting a new game. In the current development version that was changed recently, so you can now also start new games with any world add-ons you like.

As a workaround for the editor bug, you can create a new map, save it, then edit its elemental file by hand to add your add-on to the list of add-ons therein, and then load the modified map file in the editor.

Since v1.1 terrain images no longer need to be indexed PNGs. If you want your add-on to be backwards-compatible with v1.0 then indexed terrain graphics are necessary.


Top Quote
atomikaya
Avatar
Topic Opener
Joined: 2022-12-22, 22:42
Posts: 7
OS: Fedora Linux
Version: 1.1
Ranking
Pry about Widelands
Posted at: 2023-01-30, 13:28

Thank you! I guess I'll try out the terrain tiles by building a custom map then.


Top Quote