1.18 "Add-on ID" structure questions

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
kurt751
Posts: 281
Joined: June 4th, 2016, 11:17 pm

1.18 "Add-on ID" structure questions

Post by kurt751 »

I've made a couple campaigns (initially for 1.12, now ported to 1.16) and am considering switching to 1.18. But I'm not sure I understand the new add-on structure and its "ID".

Given all my campaigns happen in a specific non-Wesnoth universe with dozens of custom units, I definitely see the advantage of putting everything in one single of those add-on folders, and having all campaigns find their units, images and macros in a single place. It would not only cut down on size, but also make my life easier (only one file to update each time I make a change).

But can you put several separated campaigns in a single of those "add-on ID" folders? Is this even possible?
Or did I misunderstand the system and it's just an overhauled, more automated version of the old one, i.e. each campaign needs still to be in its own add-on folder tree?

In this case, remains the question which is the best way to handle a slew of common files without duplicating them into each campaign folder?
User avatar
Ravana
Forum Moderator
Posts: 3487
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: 1.18 "Add-on ID" structure questions

Post by Ravana »

Feels like misunderstanding, would you show which announcement or documentation you mean. You can still use multiple addons. But if you want you can also have multiple user-visible campaigns in one addon.

Addons can have dependencies, you declare them in _server.pbl. You can have dependency addon containing common part.
kurt751
Posts: 281
Joined: June 4th, 2016, 11:17 pm

Re: 1.18 "Add-on ID" structure questions

Post by kurt751 »

Ravana wrote: July 8th, 2026, 3:13 pm But if you want you can also have multiple user-visible campaigns in one addon.
That's what I'm looking for indeed. How does that work? Is there any example I can study?
Ravana wrote: July 8th, 2026, 3:13 pm Addons can have dependencies, you declare them in _server.pbl. You can have dependency addon containing common part.
I thought "_server.pbl" was just for the server upload/download management (as the name hints at), and not used by the game itself (once the files on your computer).
Can you please be more specific, ideally point me to an example?
User avatar
Ravana
Forum Moderator
Posts: 3487
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: 1.18 "Add-on ID" structure questions

Post by Ravana »

Ageless contains [modification] https://github.com/ProditorMagnus/Agele ... ce.cfg#L37 and [era] https://github.com/ProditorMagnus/Agele ... era.cfg#L4. Both are toplevel addon tags, so can be published in separate addons.

I also use images from multiple addons https://github.com/ProditorMagnus/Agele ... in.cfg#L62

_server.pbl with dependencies=Era_of_Magic_Resources,Ageless_Resources tells addon server which addons to ask user download in addition. Actual logic what you do with those addons during runtime is up to your code. Using it as binary path or reading files from it or something else.
kurt751
Posts: 281
Joined: June 4th, 2016, 11:17 pm

Re: 1.18 "Add-on ID" structure questions

Post by kurt751 »

Ravana wrote: July 8th, 2026, 3:49 pm Ageless contains [modification] https://github.com/ProditorMagnus/Agele ... ce.cfg#L37 and [era] https://github.com/ProditorMagnus/Agele ... era.cfg#L4. Both are toplevel addon tags, so can be published in separate addons.
Thanks! Though it's a little over my pay grade. :oops:
I'm no developer, I can manage with WML since it's pretty much plain English, and there are lots of examples to see what the exact syntax is, but LUA and such are totally out of my reach... :oops:
I can make (nice?) stories, but my coding skills are basic.
Ravana wrote: July 8th, 2026, 3:49 pm I also use images from multiple addons https://github.com/ProditorMagnus/Agele ... in.cfg#L62
That's what I've instinctively done too, I initially put everything common (images, macros, units, etc.) in a common folder, but it doesn't seem elegant (to me), because if I want to eventually upload one campaign I'll need to upload the campaign tree and the resource tree. And, if after that I upload another campaign, despite the resource tree being only needed once, it has to be downloaded twice just the same (because Murphy's law says that else it will be missing altogether... :roll:).
So when porting to 1.16 I went back to the old self-contained campaign folders system. It's suboptimal but at least it works.

What would be nice is to be able to put several campaigns in the same /scenario folder, and have different _main.cfg files for each (guess they would need to have personalized names, like "_main_MyFirstCampaign.cfg", "_main_MySecondCampaign.cfg"). Oh well.
Ravana wrote: July 8th, 2026, 3:49 pm _server.pbl with dependencies=Era_of_Magic_Resources,Ageless_Resources tells addon server which addons to ask user download in addition. Actual logic what you do with those addons during runtime is up to your code.
I'm not yet thinking about up/downloading. I'm still battling with final details (some scripts missing, couple images missing) for the main campaign (10 scenarios), the others are smaller ones, just for fun.
And yes, what I do with those add-ons during runtime is indeed my concern right now... :mrgreen:

Thanks for your time!
User avatar
Pentarctagon
Project Manager
Posts: 5824
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: 1.18 "Add-on ID" structure questions

Post by Pentarctagon »

kurt751 wrote: July 8th, 2026, 5:22 pm What would be nice is to be able to put several campaigns in the same /scenario folder, and have different _main.cfg files for each (guess they would need to have personalized names, like "_main_MyFirstCampaign.cfg", "_main_MySecondCampaign.cfg"). Oh well.
You can do that, you'd just need to reference each of the campaign-specific _main.cfg files from the root one.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
gnombat
Posts: 1032
Joined: June 10th, 2010, 8:49 pm

Re: 1.18 "Add-on ID" structure questions

Post by gnombat »

kurt751 wrote: July 8th, 2026, 5:22 pm Thanks! Though it's a little over my pay grade. :oops:
Maybe look at Legend of the Invincibles on the add-on server - it's one single add-on but it contains two campaigns. Is that what you want?
kurt751
Posts: 281
Joined: June 4th, 2016, 11:17 pm

Re: 1.18 "Add-on ID" structure questions

Post by kurt751 »

Pentarctagon wrote: July 8th, 2026, 5:28 pm You can do that, you'd just need to reference each of the campaign-specific _main.cfg files from the root one.
Interesting. Any example where I can check how actually this works? I'm meaning, the exact syntax?
kurt751
Posts: 281
Joined: June 4th, 2016, 11:17 pm

Re: 1.18 "Add-on ID" structure questions

Post by kurt751 »

gnombat wrote: July 8th, 2026, 5:54 pm Maybe look at Legend of the Invincibles on the add-on server - it's one single add-on but it contains two campaigns. Is that what you want?
Will do, thanks!
User avatar
Pentarctagon
Project Manager
Posts: 5824
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: 1.18 "Add-on ID" structure questions

Post by Pentarctagon »

kurt751 wrote: July 9th, 2026, 5:51 am
Pentarctagon wrote: July 8th, 2026, 5:28 pm You can do that, you'd just need to reference each of the campaign-specific _main.cfg files from the root one.
Interesting. Any example where I can check how actually this works? I'm meaning, the exact syntax?
In the root _main.cfg, use file inclusion (https://wiki.wesnoth.org/PreprocessorRe ... ive_.7B.7D) for each campaign-specific _main.cfg in other sub-folders.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
kurt751
Posts: 281
Joined: June 4th, 2016, 11:17 pm

Re: 1.18 "Add-on ID" structure questions

Post by kurt751 »

Thanks, this page helps me a lot. I've been looking for that information but couldn't find it (Because extra_defines were deprecated and the WML reference just says "define macros instead", but as incredible it might seem for developers, I needed to check how (and where) exactly you declare campaign-specific macros... :roll:).
User avatar
Pentarctagon
Project Manager
Posts: 5824
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: 1.18 "Add-on ID" structure questions

Post by Pentarctagon »

Apparently it was somehow missing from https://wiki.wesnoth.org/CampaignWML, but you'd want to use the define attribute of [campaign]. For example: https://github.com/wesnoth/wesnoth/blob ... in.cfg#L16
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
kurt751
Posts: 281
Joined: June 4th, 2016, 11:17 pm

Re: 1.18 "Add-on ID" structure questions

Post by kurt751 »

Thanks, that part I have mastered, even those new [modify_unit_type] tags I now have to use (have dozens of them in each _main.cfg...).

The part I'm still not sure about is how to best handle (declare) custom macros: Do I include them in the _main.cfg, or do I just put them in /utils/macros.cfg?
Lots of trial and (lots of) error. I usually just stick with the solution which works, even if I don't necessarily understand why it does so... :oops: :lol:

WML isn't so hard for a non-programmer, the hardest part usually being to find documentation about using some function, as opposed to just a pithy mention it exists.
User avatar
Ravana
Forum Moderator
Posts: 3487
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: 1.18 "Add-on ID" structure questions

Post by Ravana »

You need to include macros in _main.cfg, but for readability its common to put their definition in another file like utils. If you do not include them ({./utils/macros.cfg}) in _main.cfg then utils file will not be read. Wesnoth does not look files unless you tell it to look through _main.cfg.
kurt751
Posts: 281
Joined: June 4th, 2016, 11:17 pm

Re: 1.18 "Add-on ID" structure questions

Post by kurt751 »

Ravana wrote: July 11th, 2026, 7:30 am for readability its common to put their definition in another file like utils.
So I have the choice. Thanks, good to know! :D
Ravana wrote: July 11th, 2026, 7:30 amIf you do not include them ({./utils/macros.cfg}) in _main.cfg then utils file will not be read.
Yes, I know that, I have already several macros in /utils/macros.cfg, mostly custom abilities/weapon definitions.
It's the deprecation (?) of extra_defines which confused me, or rather its explanation in the CampaignWML page: It isn't clear about what exactly has changed, and since wmllint seemed to take offense on my old 1.12 extra_defines, I removed them and replaces them with a long list of [modify_unit_type] entries (which define how my custom units connect with the core ones)...
Post Reply