[modification] and preprocessor

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
User avatar
Spannerbag
Posts: 539
Joined: December 18th, 2016, 6:14 pm
Location: Yes

[modification] and preprocessor

Post by Spannerbag »

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 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
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 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
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...
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: [modification] and preprocessor

Post by gfgtdf »

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.
User avatar
Ravana
Forum Moderator
Posts: 3025
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [modification] and preprocessor

Post by Ravana »

[modification] is designed for collection of [event].
User avatar
Spannerbag
Posts: 539
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: [modification] and preprocessor

Post by Spannerbag »

gfgtdf wrote: August 2nd, 2023, 3:26 pm 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)
Ah, right. Makes sense, thanks for taking the trouble to reply.

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...
User avatar
Spannerbag
Posts: 539
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: [modification] and preprocessor

Post by Spannerbag »

Ravana wrote: August 2nd, 2023, 5:14 pm [modification] is designed for collection of [event].
I understand - ah well, have to do this without the preprocessor.
Thanks for the reply, much appreciated!

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