How do I import mainline campaign units to my campaign?

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.
Post Reply
tactics123
Posts: 8
Joined: July 30th, 2023, 3:41 am

How do I import mainline campaign units to my campaign?

Post by tactics123 »

I'm interested in importing HttT and UtBS units into my campaign. How do I do just that without copying the whole folder?
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: How do I import mainline campaign units to my campaign?

Post by Celtic_Minstrel »

Short answer: You don't.

Longer answer: If you want to use units from a mainline campaign, copy everything they need into your add-on's folder. That's the images (obviously), the unit definition files, custom races or movetypes if applicable, and any macros they use for abilities, animations, or the like.

Rationale: If you try to reference files in a mainline campaign from your add-on, there is no guarantee that your add-on will even load on another computer. Wesnoth supports running with the mainline campaigns not installed at all, so those files may or may not exist. (In practice, barring strange circumstances, they will always exist on Windows and Mac installs. Linux installs are more varied – sometimes they are included and sometimes not.)
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Pentarctagon
Project Manager
Posts: 5567
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: How do I import mainline campaign units to my campaign?

Post by Pentarctagon »

As a bit more background: some Linux distros prefer to package each campaign separately (ie: scroll down through https://packages.debian.org/search?suit ... snoth-1.16). Normally they'll all get installed anyway, but it's not 100% guaranteed depending on how the user does the installation. Whether you care about supporting that edge case on Linux is up to you.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
egallager
Posts: 584
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: How do I import mainline campaign units to my campaign?

Post by egallager »

tactics123
Posts: 8
Joined: July 30th, 2023, 3:41 am

Re: How do I import mainline campaign units to my campaign?

Post by tactics123 »

Short answer: You don't.

Longer answer: If you want to use units from a mainline campaign, copy everything they need into your add-on's folder. That's the images (obviously), the unit definition files, custom races or movetypes if applicable, and any macros they use for abilities, animations, or the like.

Rationale: If you try to reference files in a mainline campaign from your add-on, there is no guarantee that your add-on will even load on another computer. Wesnoth supports running with the mainline campaigns not installed at all, so those files may or may not exist. (In practice, barring strange circumstances, they will always exist on Windows and Mac installs. Linux installs are more varied – sometimes they are included and sometimes not.)
As a bit more background: some Linux distros prefer to package each campaign separately (ie: scroll down through https://packages.debian.org/search?suit ... snoth-1.16). Normally they'll all get installed anyway, but it's not 100% guaranteed depending on how the user does the installation. Whether you care about supporting that edge case on Linux is up to you.
Wow! Thanks for the heads up.
So the answer is to copy if you want the best support. Understood.
Thanks for the code reference! This helps alot for a newbie in WML like me.
Post Reply