WML Tutorial stuggles

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
Pikkson
Posts: 1
Joined: April 9th, 2020, 4:31 pm

WML Tutorial stuggles

Post by Pikkson »

TLDR copied code doesn't work :(

I have been struggling the Last few days with trying to understand these things. Making scenarios sounds really interesting and I also have been using the map editor for other things because this is the only hex based map editor I know.
In the end I have been getting frustrated with the code and just decided to copy it too see if it actually works.
And behold it doesn't. I am getting "scenario couldn't load" error and I have no clue what I have been doing wrong.
I have been using Atom as an editor if that has anything to do with it and I have found a few inconsistencies/have questions with the Tutorial.
Help would be appreciated.




https://wiki.wesnoth.org/WML_for_Comple ... _Chapter_3
where should "#textdomain wesnoth-my_first_campaign" go?
I Have copied the code from the tutorial, first they tell you to put the #textdomain INSIDE the scenario Tagset, but in the end they have it BEFORE the Tagset.

Code: Select all

[scenario]
#textdomain wesnoth-my_first_campaign
    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
[/scenario]

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
   [/scenario]
Dirctory
https://wiki.wesnoth.org/WML_for_Comple ... inary_Path
How should I give the directory of the map data, I don't understand how the binary path should work. So far I had both the binary path and the map data file path. Would this lead to any problems?

Code: Select all

#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
this is more of a small question, In the tutorial they don't use the period consistently. This is a translatable string so this shouldn't do anything besides be a little confusing right?

Code: Select all

[scenario] 
 name=_"My First Scenario."
 [/scenario]
gnombat
Posts: 682
Joined: June 10th, 2010, 8:49 pm

Re: WML Tutorial stuggles

Post by gnombat »

I would recommend taking a look at the WML Guide add-on. It's intended as a tutorial for WML, and it's newer and more up-to-date than the tutorial on the wiki.

Also, it's a working campaign, so it's guaranteed to actually run without errors. :D
Pikkson wrote: October 20th, 2021, 12:44 pm where should "#textdomain wesnoth-my_first_campaign" go?
I Have copied the code from the tutorial, first they tell you to put the #textdomain INSIDE the scenario Tagset, but in the end they have it BEFORE the Tagset.
Honestly I can't recall offhand where it's supposed to go - I would just take a look at what the WML Guide does and copy that.
Pikkson wrote: October 20th, 2021, 12:44 pm this is more of a small question, In the tutorial they don't use the period consistently. This is a translatable string so this shouldn't do anything besides be a little confusing right?

Code: Select all

[scenario] 
 name=_"My First Scenario."
 [/scenario]
Yes, it's just a translatable string for display purposes, so it should work with or without the period.
User avatar
Jarom
Posts: 110
Joined: January 4th, 2015, 8:23 pm
Location: Green Isle, Irdya or Poland, Earth - I'm not quite sure

Re: WML Tutorial stuggles

Post by Jarom »

First, to address the textdomain question: #textdomain wesnoth-sth can go anywhere, as long as it's before the first translatable string. There can even be more #textdomain directives in one file, in this case textdomain will switch with each one. However, strong recommendation is to put a single #textdomain directive as first line, before any other tags, and I think this is checked by wmllint.

Second, as for map question, I personally recommend using map_file instead of map_data. It should look like:

Code: Select all

map_file = "my_first_map.map"
This will use a conjuction of: the path you gave in [binary_path] (in your example it'll be data/add-ons/my_first_campaign), the "/maps/" part and then whatever you gave in map_file key. But if you still need to use map_data for some reason, you need to understand file referencing - you can use {} to include a different file directly in your code during preprocessing, which in this case means that for the game your scenario's cfg file will contain the whole content of .map file between "" quote marks after map_data=, and binary path will be irrelevant to this. As a side note, binary path will also allow you to use relative paths for images and music.

However, your map_data path looks fine, so you probably made a mistake somewhere else. Aside from validating file structure, which might be beyond beginner's abilities, I recommend adding 1-2 [side] tags to your scenario already.

For the period in translatables, it should only affects display. Usually scenario names don't have the dot though, so I don't know if it won't cause any problems with save filenames (those use translated scenario names!).
Post Reply