Struggling with first 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
Kal_Ultor
Posts: 17
Joined: April 28th, 2023, 12:01 pm
Location: Central Europe

Struggling with first campaign

Post by Kal_Ultor »

Hi,
I started today with the tutorial for making your down campaign ( https://wiki.wesnoth.org/WML_for_Complete_Beginners ). I followed the tutorial to including step 4 and wanted to try out the first scenario. But I receive the following Error Message:
"The following add-on had errors and could not be loaded:
/Users/Kal_Ultor/Library/Containers/org.wesnoth.Wesnoth/Data/Library/Application Support/Wesnoth_1.16/data/add-ons/my_first_campaign/_main.cfg

Please report this to the author or maintainer of this add-on.

Details:

Macro/file '\fonttbl\f0\fnil\fcharset0' is missing
at ~add-ons/my_first_campaign/_main.cfg:2"

How do I fix it?

In case it is important:
- I use a MacBook Pro MacOs Monterey
- Version of Battle for Wesnoth: 1.16.8
- I wrote both files, "_main.cfg" and, "my_first_scenario.cfg" in TextEdit, saved them with the Suffix ".rtf" and replaced it via Information following this tutorial: https://www.alphr.com/create-cfg-file/
- both files are stored in the following direction: Wesnoth_1.16/data/add-ons/my_first_campaign (so in the my_first_campaign Folder)

Thank you for your help!

My Code (Even though I copied and pasted it)
_main.cfg

Code: Select all

[textdomain]
    name="wesnoth-my_first_campaign"
    path="data/add-ons/my_first_campaign/translations"
[/textdomain]

#textdomain wesnoth-my_first_campaign

[campaign]
    #wesnoth-My_First_Campaign
    id=my_first_campaign
    name= _ "My First Campaign"
    abbrev= _ "MFC"
    define=CAMPAIGN_MY_FIRST_CAMPAIGN
#need icon and image (take from core files, don't include external files for sake of simplicity)
    icon=
    image=
    first_scenario=my_first_scenario
    description= _ "This is my first campaign."
    {CAMPAIGN_DIFFICULTY EASY  "units/human-loyalists/spearman.png~RC(magenta>red)" ( _ "Spearman") ( _ "Normal")}
[/campaign]

#ifdef CAMPAIGN_MY_FIRST_CAMPAIGN

[binary_path]
    path=data/add-ons/my_first_campaign
[/binary_path]

{~add-ons/my_first_campaign/macros}
{~add-ons/my_first_campaign/utils}

{~add-ons/my_first_campaign/scenarios}
#endif
my_first_scenario.cfg

Code: Select all

#textdomain wesnoth-my_first_campaign
[scenario]
    id=my_first_scenario
    next_scenario=null
    name=_"My First Scenario."
    map_data="{~add-ons/my_first_campaign/maps/my_first_map.map}"
    turns=30
    [side]
        side=1
        controller=human
        team_name="good"
        user_team_name= _ "My Team"
        id=MyLeader
        name= _ "My Leader's Name"
        type="Elvish Ranger"
        unrenameable=yes
        canrecruit=yes
        recruit="Elvish Fighter, Elvish Archer, Elvish Shaman"
        gold=100
    [/side]
    [side]
       side=2
       controller=ai
       team_name="bad"
       user_team_name= _ "Bad Guys"
       id="EnemyLeader"
       name= _ "My Villain"
       type= "Orcish Warrior"
       unrenameable=yes
       canrecruit=yes
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider"
       gold=100
    [/side]
[/scenario]
gnombat
Posts: 710
Joined: June 10th, 2010, 8:49 pm

Re: Struggling with first campaign

Post by gnombat »

Kal_Ultor wrote: April 28th, 2023, 12:14 pm - I wrote both files, "_main.cfg" and, "my_first_scenario.cfg" in TextEdit, saved them with the Suffix ".rtf"
".rtf" stands for Rich Text Format, which won't work - you need to save the file as plain text.

I don't use a Mac, so I'm not sure how you save as plain text in TextEdit, but according to the Wikipedia article on TextEdit it does support plain text, so it should be possible. It might work if you use the suffix ".txt" instead of ".rtf". Then you'll have to rename it to ".cfg" as you did before.
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Struggling with first campaign

Post by Celtic_Minstrel »

When editing in TextEdit, you need to choose "Make Plain Text" from the Format menu before saving the file. That will cause TextEdit to add a ".txt" extension by default, but I'm pretty sure you can change it to ".cfg" right in the save box.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Kal_Ultor
Posts: 17
Joined: April 28th, 2023, 12:01 pm
Location: Central Europe

Re: Struggling with first campaign

Post by Kal_Ultor »

Thank you for your help. I did, as you said. Now I can find the campaign in the campaign menu. However, when I choose it, I just receive an error message:
Error – Failed to load the scenario
What can I do about it?
gnombat
Posts: 710
Joined: June 10th, 2010, 8:49 pm

Re: Struggling with first campaign

Post by gnombat »

Did you put the file "my_first_scenario.cfg" directly in the "my_first_campaign" folder? It should be in a subfolder named "scenarios".
Kal_Ultor
Posts: 17
Joined: April 28th, 2023, 12:01 pm
Location: Central Europe

Re: Struggling with first campaign

Post by Kal_Ultor »

It is now in the "scenarios" folder, but I still receive the error message
gnombat
Posts: 710
Joined: June 10th, 2010, 8:49 pm

Re: Struggling with first campaign

Post by gnombat »

You may need to check your logs folder, it will probably have more error details.

Your logs folder should be located at:
Wesnoth_1.16/logs

Look in the most recently created log file in that folder for error messages.
User avatar
Straff
Posts: 87
Joined: September 27th, 2020, 2:53 pm

Re: Struggling with first campaign

Post by Straff »

If I rename

Code: Select all

unrenameable
to

Code: Select all

unrenamable
(2x), then your campaign loads on my side.
Kal_Ultor
Posts: 17
Joined: April 28th, 2023, 12:01 pm
Location: Central Europe

Re: Struggling with first campaign

Post by Kal_Ultor »

Thank you! @Straff's fix worked.
User avatar
Spannerbag
Posts: 538
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Struggling with first campaign

Post by Spannerbag »

Kal_Ultor wrote: April 28th, 2023, 12:14 pm Hi,
I started today with the tutorial for making your down campaign ...
Hi,
it's probably a bit too late now but here are a couple of add-ons that might help?
Assuming you're using Wesnoth v1.16 then there are these that might help:
Campaign-How-To (A Simple Campaign) and maybe Helmet's DIY Campaign.

I use my own home-brewed stub campaign when testing but the ones above have (hopefully) better documentation :)

IIRC I think Campaign-How-To (A Simple Campaign) might be available in earlier versions of Wesnoth as A Simple Campaign.
No idea if it's changed much between versions though.

Good luck with your campaign!

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
Kal_Ultor
Posts: 17
Joined: April 28th, 2023, 12:01 pm
Location: Central Europe

Re: Struggling with first campaign

Post by Kal_Ultor »

@Spannerbag, Thank you, they are indeed very helpful. But I ran into another issue. I am trying to make it possible to board and unboard a galleon. However, I received this error message for the last 2 hours and couldn't find a way to fix it:

Unexpected characters after variable name (expected , or =)
at ~add-ons/my_first_campaign/scenarios/my_first_scenario.cfg:82
included from ~add-ons/my_first_campaign/_main.cfg:31

My Code:
Spoiler:
User avatar
Spannerbag
Posts: 538
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Struggling with first campaign

Post by Spannerbag »

Kal_Ultor wrote: April 30th, 2023, 9:33 am @Spannerbag, Thank you, they are indeed very helpful...
Glad to hear it :D
Kal_Ultor wrote: April 30th, 2023, 9:33 am ...
Unexpected characters after variable name (expected , or =)
at ~add-ons/my_first_campaign/scenarios/my_first_scenario.cfg:82
included from ~add-ons/my_first_campaign/_main.cfg:31...
description= _ "Board this unit onto the galleon."
First off, whenever you get this sort of message it gives you the line number:
at ~add-ons/my_first_campaign/scenarios/my_first_scenario.cfg:82

So I copied your code into a text editor, went to line number 82 and looked around nearby and found this:

Code: Select all

        [show_if]
                canrecruit=yes
                not
                    has_unit_variable("boarded_units", "$unit_id")
        [/show_if]

Which is broken in several ways.

First off [show_if] wants a true/false value so whatever is inside needs to be something like [have_unit] or [variable].
A good reference is the condition tags section of the ConditionalActionsWML wiki page. Once that's correctly structured you can work through the actual logic.

Presumably, if you remove the transport related code everything else works fine?
If you haven't done that it might be worth testing that the basic campaign structure is sound (apologies if you've already done this).

FWIW I use the DEBUG_MSG (macros/debug-utils) when testing to report on variables and whether or not a section of code actually executes. It's very handy and better than :inspect because it reports at execution time.

Code: Select all

#define DEBUG_MSG MESSAGE_TEXT
    # Emit a debug message.  Meant to be overridden with no-op definition
    # of the same name for production use.
    [message]
        speaker=narrator
        message={MESSAGE_TEXT}
        image=wesnoth-icon.png
    [/message]
#enddef
I appreciate I haven't answered all your queries but some things cannot be resolved until after others are fixed. Once you know you have a working campaign except for embark/disembark then you can get that working knowing that any errors that arise are from stuff you've added (though as I have learned from painful experience that doesn't mean that the actual fix only involves changing addded code, sometimes the new code can expose shortcomings or invalid assumptions in existing - and previously working - code :augh:).

My motto: Take small steps. Test often.

Hope this helps.

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
Post Reply