[modification] and preprocessor
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.
- Spannerbag
- Posts: 539
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
[modification] and preprocessor
Hi,
I'm never written a [modification] and decided to see what was possible.
What I am trying to do
As a test I'm seeing if I can change {DEFAULT_AMLA} - here I'm just trying to add a bit of extra text to the description to report that the mod has done something.
I understand the scoping rules probably won't allow this but thought I'd test it anyway.
The problem
Though selectable in-game (i.e. is listed as a mod) it never does anything.
However I'm a bit stuck in digging into the cause and was hoping someone cleverer than me could point out what's wrong?
(I can think of multiple reasons such as version numbering, the fact that the mod wasn't installed from the add-ons server, incorrect use of symbol created by
The code
Just a
To test, I added the following to my test scenario:
It always reports the #else message (not enabled).
I suspect that this is may be to do with timing?
When the mod loads the preprocessor has already run and isn't re-run when the mod is activated?
(I.e. incorrect use of symbol created by
Any advice gratefully received!
I can probably still write the mod without the above logic but it might've helped simplify a few things if I could change default macros.
Thanks,
-- Spannerbag
I'm never written a [modification] and decided to see what was possible.
What I am trying to do
As a test I'm seeing if I can change {DEFAULT_AMLA} - here I'm just trying to add a bit of extra text to the description to report that the mod has done something.
I understand the scoping rules probably won't allow this but thought I'd test it anyway.
The problem
Though selectable in-game (i.e. is listed as a mod) it never does anything.
However I'm a bit stuck in digging into the cause and was hoping someone cleverer than me could point out what's wrong?
(I can think of multiple reasons such as version numbering, the fact that the mod wasn't installed from the add-ons server, incorrect use of symbol created by
define=
and so forth.)The code
Just a
_main.cfg
, nothing else.Code: Select all
#textdomain wesnoth-spamla
[modification]
type=sp
id=spamla_0.1
name=_"TEST Default Amla override mod"
description=_"Replaces DEFAULT_AMLA macro with whatever is specified in this mod."
# addon_min_version # Maybe later
define=SPAMLA
#
# # undef DEFAULT_AMLA
[/modification]
#ifdef SPAMLA
#ifdef DEFAULT_AMLA
#define DEFAULT_AMLA
# Canned definition of the default AMLA.
[advancement]
strict_amla=yes
max_times=100
id=amla_default
description= _ "Max HP bonus +3, Max XP +20% spamla mod active"
image="icons/amla-default.png"
[effect]
apply_to=hitpoints
increase_total=3
heal_full=yes
[/effect]
[effect]
apply_to=max_experience
increase=20%
[/effect]
[effect]
apply_to=status
remove=poisoned
[/effect]
[effect]
apply_to=status
remove=slowed
[/effect]
[/advancement]
#enddef
#endif
#define SPAMLA_ENABLED_MSG
[message]
speaker=narrator
message=_"Spamla enabled"
[/message]
#enddef
#endif
To test, I added the following to my test scenario:
Code: Select all
#ifdef SPAMLA_ENABLED_MSG
{SPAMLA_ENABLED_MSG}
#else
[message]
speaker=narrator
message=_"Spamla NOT enabled"
[/message]
#endif
I suspect that this is may be to do with timing?
When the mod loads the preprocessor has already run and isn't re-run when the mod is activated?
(I.e. incorrect use of symbol created by
define=
as mentioned above...).Any advice gratefully received!
I can probably still write the mod without the above logic but it might've helped simplify a few things if I could change default macros.
Thanks,
-- Spannerbag
Re: [modification] and preprocessor
I'm not sure whether i understood your problem correctly, but all addons (and mainline) are preprocecced separately, Do if you re-define a macro in your addon it will only effect that addon. (and only those parts that are preprocecced after the redefinition)
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Re: [modification] and preprocessor
[modification] is designed for collection of [event].
- Spannerbag
- Posts: 539
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: [modification] and preprocessor
Ah, right. Makes sense, thanks for taking the trouble to reply.
Cheers!
-- Spannerbag
- Spannerbag
- Posts: 539
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: [modification] and preprocessor
I understand - ah well, have to do this without the preprocessor.
Thanks for the reply, much appreciated!
Cheers!
-- Spannerbag