Correct string to user content
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.
Correct string to user content
Hello Wesnoth community,
I know Wesnoth since many years and have played some of the campaigns. Now I would like to go a bit further and create my own maps and scenarios. Doing this, I encoutered a problem.
I have created a map named k1 and saved it here: "C:\Users\Oliver\Documents\My Games\Wesnoth1.14\editor\maps\k1.map"
I have created a scenario s01 and saved it here: "C:\Users\Oliver\Documents\My Games\Wesnoth1.14\editor\scenarios\s01.cfg"
Within the sceanrio file, I use this statement.
No problem, everything is fine.
When I use this statement instead I get an error message whenever I try to start a local multiplayer game.
I have tried these statements, too. But all do throw the same error message.
map_data=maps/k1.map
map_data=/maps/k1.map
map_data=editor/maps/k1.map
map_data=/editor/maps/k1.map
map_data="C:\Users\Oliver\Documents\My Games\Wesnoth1.14\editor\maps\k1.map"
So what statement do I have to use to get it right ?
Please note that I am using Wesnoth on a Windows 10 64-bit System.
https://drive.google.com/file/d/1PaTzEG ... sp=sharing
I know Wesnoth since many years and have played some of the campaigns. Now I would like to go a bit further and create my own maps and scenarios. Doing this, I encoutered a problem.
I have created a map named k1 and saved it here: "C:\Users\Oliver\Documents\My Games\Wesnoth1.14\editor\maps\k1.map"
I have created a scenario s01 and saved it here: "C:\Users\Oliver\Documents\My Games\Wesnoth1.14\editor\scenarios\s01.cfg"
Within the sceanrio file, I use this statement.
Code: Select all
map_data="Gg, Gg, …"
When I use this statement instead
Code: Select all
map_data="k1.map"
I have tried these statements, too. But all do throw the same error message.
map_data=maps/k1.map
map_data=/maps/k1.map
map_data=editor/maps/k1.map
map_data=/editor/maps/k1.map
map_data="C:\Users\Oliver\Documents\My Games\Wesnoth1.14\editor\maps\k1.map"
So what statement do I have to use to get it right ?
Please note that I am using Wesnoth on a Windows 10 64-bit System.
https://drive.google.com/file/d/1PaTzEG ... sp=sharing
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Correct string to user content
It should be
map_data="{path/to/k1.map}"
. From mainline, for example: map_data="{multiplayer/maps/2p_Aethermaw.map}"
.99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: Correct string to user content
You should instead use map_file if you have path to file
https://github.com/wesnoth/wesnoth/issues/3357
https://github.com/wesnoth/wesnoth/issues/3357
Re: Correct string to user content
First of all, thx for yours answers.
Second, none of the answers were solving the problem. But after some extensive tests, they led to the answer
Whenever I put the map file into the user data directory, it is recognised by the map editor but it is NEVER recognised by the scenario file.
Whenever I put the map file into the game data directory, it is ALWAYS recognised by the scenario file.
My logical conclusion is that the user data directory is excluded from the Wesnoth search path while the scenario file is being parsed. Can someone please check if he is also affected by this problem ?
Second, none of the answers were solving the problem. But after some extensive tests, they led to the answer
Whenever I put the map file into the user data directory, it is recognised by the map editor but it is NEVER recognised by the scenario file.
Whenever I put the map file into the game data directory, it is ALWAYS recognised by the scenario file.
My logical conclusion is that the user data directory is excluded from the Wesnoth search path while the scenario file is being parsed. Can someone please check if he is also affected by this problem ?
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Correct string to user content
You should probably read this page, I think.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
- Celtic_Minstrel
- Developer
- Posts: 2216
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Correct string to user content
You might be able to get it to work with
map_file="../maps/k1.map"
? But I think the best option here is to actually create a proper addon, as described by Pentarctagon's link.Re: Correct string to user content
Well, I think I have to give you much more info.
1. I dont want to publish my user made content at the moment. I am fully aware that if I want to publish it, I have to create an add-on, follow the guidelines, etc.
2. I dont want to use translateable strings. This makes things a little bit easier as I dont need to create a translation file and I dont need to specify a textdomain.
A. To test things out, I have made this little scenario 'scenariotest1.cfg' and saved it at userdata/editor/scenarios. Here is the content.
This scenario is working fine. Due to this, my first questions are:
Do I have to create an add-on for every scenario or is it just optional ?
If you answer that an add-on is a must-have, why is my sceanrio working without one ?
B.
Now I do the following:
I take the map string and put it into a new file named 'maptest.map' and save it at userdata/editor/maps. The map file can be loaded, changed and saved by the map editor so everything is fine.
I create another scenario, name it 'scenariotest2.cfg' and saved it at userdata/editor/scenarios. Here is the content.
I remove the # tag from the first line with a map_data tag and save it. Then I start Wesnoth, create a new local multiplayer game and check if it works. I close Wesnoth, put a # in front of the first line with a map_data tag and remove the # from the second line with a map_data tag. So in total I was checking 32 different map_data or map_file tags. None of them worked. Some of them threw another error message.
https://drive.google.com/file/d/1Y3T5ad ... sp=sharing
After being frustrated and exhausted to the fullest, I just read some others people scenario files. Then an idea came to my mind. Just break the rules and put my map directly to the game folder: 'data/campaigns/campaigntest'. I deleted all map_data and map_file tags from scenariotest2.cfg and added this line
Bingo !!! The sceanrio works now !!!!!
Can someone please explain this behavior to me ?
Thx a lot.
1. I dont want to publish my user made content at the moment. I am fully aware that if I want to publish it, I have to create an add-on, follow the guidelines, etc.
2. I dont want to use translateable strings. This makes things a little bit easier as I dont need to create a translation file and I dont need to specify a textdomain.
A. To test things out, I have made this little scenario 'scenariotest1.cfg' and saved it at userdata/editor/scenarios. Here is the content.
Code: Select all
current_time=0
description=""
experience_modifier=70
id="scenariotest1"
map_data="Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg
Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg
Gg, Gg, Gg, Gg, Ce, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Ce, Gg, Gg, Gg, Gg
Gg, Gg, Gg, Ce, 1 Kh, Ce, Gg, Gg, Gg, Gg, Gg, Ce, 2 Kh, Ce, Gg, Gg, Gg
Gg, Gg, Gg, Ce, Ce, Ce, Gg, Gg, Gg, Gg, Gg, Ce, Ce, Ce, Gg, Gg, Gg
Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg
Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg
Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg
Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg
Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg
Gg, Gg, Gg, Gg, Ce, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Ce, Gg, Gg, Gg, Gg
Gg, Gg, Gg, Ce, 4 Kh, Ce, Gg, Gg, Gg, Gg, Gg, Ce, 3 Kh, Ce, Gg, Gg, Gg
Gg, Gg, Gg, Ce, Ce, Ce, Gg, Gg, Gg, Gg, Gg, Ce, Ce, Ce, Gg, Gg, Gg
Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg
Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg, Gg
"
name="scenariotest1"
victory_when_enemies_defeated=yes
[time]
blue=0
green=-15
id="dawn"
image="misc/time-schedules/default/schedule-dawn.png"
lawful_bonus=0
name=_"Dawn"
red=-25
sound="ambient/morning.ogg"
[/time]
[time]
blue=0
green=0
id="morning"
image="misc/time-schedules/default/schedule-morning.png"
lawful_bonus=25
name=_"Morning"
red=0
[/time]
[time]
blue=0
green=0
id="afternoon"
image="misc/time-schedules/default/schedule-afternoon.png"
lawful_bonus=25
name=_"Afternoon"
red=0
[/time]
[time]
blue=-35
green=-20
id="dusk"
image="misc/time-schedules/default/schedule-dusk.png"
lawful_bonus=0
name=_"Dusk"
red=10
sound="ambient/night.ogg"
[/time]
[time]
blue=-13
green=-45
id="first_watch"
image="misc/time-schedules/default/schedule-firstwatch.png"
lawful_bonus=-25
name=_"First Watch"
red=-75
[/time]
[time]
blue=-13
green=-45
id="second_watch"
image="misc/time-schedules/default/schedule-secondwatch.png"
lawful_bonus=-25
name=_"Second Watch"
red=-75
[/time]
Do I have to create an add-on for every scenario or is it just optional ?
If you answer that an add-on is a must-have, why is my sceanrio working without one ?
B.
Now I do the following:
I take the map string and put it into a new file named 'maptest.map' and save it at userdata/editor/maps. The map file can be loaded, changed and saved by the map editor so everything is fine.
I create another scenario, name it 'scenariotest2.cfg' and saved it at userdata/editor/scenarios. Here is the content.
Code: Select all
current_time=0
description=""
experience_modifier=70
id="scenariotest2"
#map_data="maptest.map"
#map_data="maps/maptest.map"
#map_data="editor/maps/maptest.map"
#map_data="{maptest.map}"
#map_data="{maps/maptest.map}"
#map_data="{editor/maps/maptest.map}"
#map_file="maptest.map"
#map_file="maps/maptest.map"
#map_file="editor/maps/maptest.map"
#map_file="{maptest.map}"
#map_file="{maps/maptest.map}"
#map_file="{editor/maps/maptest.map}"
#map_data="../maptest.map"
#map_data="../maps/maptest.map"
#map_data="../editor/maps/maptest.map"
#map_data="../{maptest.map}"
#map_data="../{maps/maptest.map}"
#map_data="../{editor/maps/maptest.map}"
#map_file="../maptest.map"
#map_file="../maps/maptest.map"
#map_file="../editor/maps/maptest.map"
#map_file="../{maptest.map}"
#map_file="../{maps/maptest.map}"
#map_file="../{editor/maps/maptest.map}"
#map_data="data/add-ons/maptest.map"
#map_data="{data/add-ons/maptest.map}"
#map_file="data/add-ons/maptest.map"
#map_file="{data/add-ons/maptest.map}"
#map_data="userdata/add-ons/maptest.map"
#map_data="{userdata/add-ons/maptest.map}"
#map_file="userdata/add-ons/maptest.map"
#map_file="{userdata/add-ons/maptest.map}"
#None of the above paths are working.
name="scenariotest2"
victory_when_enemies_defeated=yes
[time]
blue=0
green=-15
id="dawn"
image="misc/time-schedules/default/schedule-dawn.png"
lawful_bonus=0
#textdomain wesnoth-help
name=_"Dawn"
red=-25
sound="ambient/morning.ogg"
[/time]
[time]
blue=0
green=0
id="morning"
image="misc/time-schedules/default/schedule-morning.png"
lawful_bonus=25
name=_"Morning"
red=0
[/time]
[time]
blue=0
green=0
id="afternoon"
image="misc/time-schedules/default/schedule-afternoon.png"
lawful_bonus=25
name=_"Afternoon"
red=0
[/time]
[time]
blue=-35
green=-20
id="dusk"
image="misc/time-schedules/default/schedule-dusk.png"
lawful_bonus=0
name=_"Dusk"
red=10
sound="ambient/night.ogg"
[/time]
[time]
blue=-13
green=-45
id="first_watch"
image="misc/time-schedules/default/schedule-firstwatch.png"
lawful_bonus=-25
name=_"First Watch"
red=-75
[/time]
[time]
blue=-13
green=-45
id="second_watch"
image="misc/time-schedules/default/schedule-secondwatch.png"
lawful_bonus=-25
name=_"Second Watch"
red=-75
[/time]
https://drive.google.com/file/d/1Y3T5ad ... sp=sharing
After being frustrated and exhausted to the fullest, I just read some others people scenario files. Then an idea came to my mind. Just break the rules and put my map directly to the game folder: 'data/campaigns/campaigntest'. I deleted all map_data and map_file tags from scenariotest2.cfg and added this line
Code: Select all
map_data="{campaigns/campaigntest/maptest.map}"
Can someone please explain this behavior to me ?
Thx a lot.
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Correct string to user content
I suppose structuring your scenario like a proper add-on isn't technically required, but you don't have to follow any sort of guidelines if you don't upload it. Following a normal add-ons structure will also make it a lot easier to do pretty much everything else though, including answering questions about it.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: Correct string to user content
For preprocessor calls (that's everything using curly braces):
The preprocessor is essentially reading what is written in a file and inserts it at the place it is called. It's used with
According to the file you posted
Edit: The preprocessor is documented here, the above in section 2.4: https://wiki.wesnoth.org/PreprocessorRef
{some/file.cfg}
will look for files or directories located in the data folder of the main game.{~some/file.cfg}
will look for files in the data folder of the users stuff. This one is often used in add-ons, but it cannot reach the editor folder as it is no subdirectory.{./some/file.cfg}
starts looking in the same directory as the file is. It's the only way to read another file not being in an add-on or the main game via the preprocessor. Probably what you want. — But, also here you can only load a file in a subdirectory.{../some/file.cfg}
is not supported (just mentioning for completeness. ..
is a way to reach the directory below in unix systems.)The preprocessor is essentially reading what is written in a file and inserts it at the place it is called. It's used with
map_data
.map_file
is not using the preprocessor (no curly braces), thus the above rules don't have to be the same. But you can try out the 4 ways above without curly braces, it's likely that the rules are similar or the same.According to the file you posted
..
also doesn't work here, so you can only load subdirectories (probably to avoid add-ons reading you non-wesnoth files). What you can do though is to learn about symlinks (or hardlinks) – that way a file can exist in multiple directories. That's an OS level thing, and on Microsoft Windows it requires admin privileges.Edit: The preprocessor is documented here, the above in section 2.4: https://wiki.wesnoth.org/PreprocessorRef
Try out the dark board theme.
- Celtic_Minstrel
- Developer
- Posts: 2216
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Correct string to user content
If you want to save your scenario in
Preprocessor inclusion in a scenario in
userdata/editor/scenarios
, I suspect it must all be self-contained in a single file. So, if you copy-paste the contents of maptest.map into those quotes, I think that would work.Preprocessor inclusion in a scenario in
userdata/editor/scenarios
might be able to pick up files in the same folder, so you could also try moving maptest.map to that folder and including it as map_data={./maptest.map}
, You certainly won't be able to include anything from userdata/editor/maps
though, since that lies outside the WML "virtual filesystem" (as does userdata/editor/scenarios
).Re: Correct string to user content
Dear Shiki, dear Celtic, thx for your help. Your answers were exactly what I was looking for. I saved my map file to
From the sceanrio file, I can refer to the map by using
I will go on studying some of the built-in campaigns to become firm with the WML tags.
Code: Select all
userdata/editor/scenarios/smaps/maptest.map
Code: Select all
map_data="{./smaps/maptest.map}"