Using relative paths in quotes
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.
Using relative paths in quotes
Hi. I try to make a template for a multiplayer campaign for testing scripts.
I want to make renaming the campaign as easy as possible.
So, I try to use macros. But I can't quite figure out if it is ok to use macro within quotes.
If I can use relative paths for everything instead of using macros, it would be even better. But I don't know if that is possible.
_main.cfg:
I want to make renaming the campaign as easy as possible.
So, I try to use macros. But I can't quite figure out if it is ok to use macro within quotes.
If I can use relative paths for everything instead of using macros, it would be even better. But I don't know if that is possible.
_main.cfg:
Code: Select all
#textdomain wesnoth-Blank_MP_Scenario
#define SCENARIO_NAME
Blank_MP_Scenario#enddef
#define LD __PATH__
{~add-ons/{SCENARIO_NAME}/{__PATH__}}#enddef
[textdomain]
name="wesnoth-{SCENARIO_NAME}"
path="{LD translations}"
[/textdomain]
#ifdef MULTIPLAYER
[binary_path]
path="data/add-ons2/{SCENARIO_NAME}"
[/binary_path]
[lua]
code = << wesnoth.message '>>+"wesnoth-{SCENARIO_NAME}"+<<>>'
[/lua]
{LD scenarios/main.cfg}
#endif
Last edited by Yutmeal2 on October 16th, 2017, 2:26 am, edited 1 time in total.
Re: Quoted path containing macros
There is support for relative paths https://wiki.wesnoth.org/PreprocessorRe ... inclusions.
Re: Quoted path containing macros
Thanks, Ravana. I changed all includes to:
It seems that something like this in "scenario/main.cfg" works:
Setting variable doesn't work:
in main.cfg:
in scenario/main.cfg:
Code: Select all
{./<relative Path>}
Code: Select all
map_data="{LD maps/map0.map}"
in main.cfg:
Code: Select all
[set_variable]
name=scenario_name
value="Blank_MP_Scenario"
[/set_variable]
[set_variable]
name=homedir
value="~add-ons/"+$scenario_name+"/"
[/set_variable]
Code: Select all
[multiplayer]
id=multiplayer_Blank_Scenario
name= _ "2p — Blank Scenario"
map_data=$homedir+"map/map0.map"
...
Re: Using relative paths in quotes
That's because variables aren't substituted in places like [multiplayer] map_data=, or probably any other top-level scenario keys like that.
But if your only goal is to make it easier to rename the campaign, then just get a tool that can perform text-based search-and-replace in a whole directory; there's no real need to complicate your code to allow a change like that to happen in one place. For example, I use a program called grepWin for exactly those kinds of tasks, and I rarely require anything more.
But if your only goal is to make it easier to rename the campaign, then just get a tool that can perform text-based search-and-replace in a whole directory; there's no real need to complicate your code to allow a change like that to happen in one place. For example, I use a program called grepWin for exactly those kinds of tasks, and I rarely require anything more.