Owl's WML (Currently: Solved)

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
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Owl's WML (Currently: Solved)

Post by UnwiseOwl »

Hey guys, I'm hoping that one of the wizards out there can help me out, as I've reached the not-very-difficult-to-reach limit of my wml abilities. I hope this is the place.

I'm working on a campaign that has got pretty wordy. I want to keep the wordy version, it's great colour and gives much more emotional depth to the campaign, but have an option for those who just want to have the fights to do so without having to wade through reams of discussion.

I had hoped to do this by giving an option box after choosing the difficulty setting, with an explanation and then options for "keep words", "kill words", that will allow the define a variable that carries over the whole campaign, so that I can put the great swathes of text inside if 'var=keep_words' (or similar) tags and just keep the bare bones for those who want that option.

I THINK this might be possible using the extra_defines= option in the main.cfg of the campaign, but am unsure of a)how to do this, b)how to present the user with the choice and c) if this is the best way. Any advice?
Last edited by UnwiseOwl on April 18th, 2017, 1:25 pm, edited 30 times in total.
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Using extradefines= to give players extra campaign optio

Post by zookeeper »

UnwiseOwl wrote:I had hoped to do this by giving an option box after choosing the difficulty setting, with an explanation and then options for "keep words", "kill words", that will allow the define a variable that carries over the whole campaign, so that I can put the great swathes of text inside if 'var=keep_words' (or similar) tags and just keep the bare bones for those who want that option.

I THINK this might be possible using the extra_defines= option in the main.cfg of the campaign, but am unsure of a)how to do this, b)how to present the user with the choice and c) if this is the best way. Any advice?
Well, you could allow the user to choose in the difficulty menu, but that's not good since you haven't had time to explain what the choice is really about at that point. Other than that, preprocessor defines can't really help you.

What you probably want is to simply pop up a [message] with [option]s at the start of the first scenario (or whenever you want, really) which sets a variable based on the user's choice. Then you can just use an [if] to check the variable during whichever piece of dialogue you want (creating a custom macro or two to make it faster to write all those checks sounds like a good idea, too).

Code: Select all

[message]
    ...
    
    [option]
        ...
        
        [command]
            {VARIABLE wordytext yes}
        [/command]
    [/option]

    [option]
        ...
        
        [command]
            {VARIABLE wordytext no}
        [/command]
    [/option]
[/message]

[if]
    [variable]
        name=wordytext
        boolean_equals=yes
    [/variable]

    [then]
        ...
    [/then]

    [else]
        ...
    [/else]
[/if]
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Using extradefines= to give players extra campaign optio

Post by UnwiseOwl »

Thanks, zookeeper. That's exactly what I'm after. I'll give it a try some time tonight.
I'm a little bit scared about venturing into the great unknown world of custom macros, but I guess it'll depend how annoyed I get with copypasting...
EDIT: Works just fine, once I realised that I had to put it inside an event...I am dense sometimes.
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Using extradefines= to give players extra campaign optio

Post by UnwiseOwl »

Apologies for the double:

Something further to that, I caved and tried to create those custom macros that you spoke of, zookeeper, and I've come up with this. I haven't tested it yet:

Code: Select all

#define TALK UNITID MESSAGE
#works irrespective of wordytext value
    [message]             
        id={UNITID}
        message= _ {MESSAGE}
    [/message]

#define TALKWORDY UNITID MESSAGE
#only works for wordytext=yes
    [message]
        [showif]
            [variable]
                name=wordytext
                boolean_equals=yes
            [/variable]
        [/showif]
        id={UNITID}
        message= _ {MESSAGE}
    [/message]

#define TALKUNWORDY UNITID MESSAGE
#only works for wordytex=no
    [message]
        [showif]
            [variable]
                name=wordytext
                boolean_equals=no
            [/variable]
        [/showif]
        id={UNITID}
        message= _ {MESSAGE}
    [/message]
I believe that this will work (assuming you can put text strings into a macro like that...), but wonder if anyone can tell me a way to make this more efficient by combining all of these into one macro, defining another variable in the macro string that could be for example yes,no,all.

Any ideas?
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
User avatar
Pentarctagon
Project Manager
Posts: 5562
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Using extradefines= to give players extra campaign optio

Post by Pentarctagon »

Just make sure you put quotes around the string argument when using the macro.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Using extradefines= to give players extra campaign optio

Post by UnwiseOwl »

That was the plan. Much nicer than multiple lines of if/then code everywhere. Thanks guys.
(Why why why, turin, did you place spaces in all your character ids?)

EDIT: Gotta end the definitions too, of course. Doh.
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
User avatar
Crendgrim
Moderator Emeritus
Posts: 1328
Joined: October 15th, 2010, 10:39 am
Location: Germany

Re: Using extradefines= to give players extra campaign optio

Post by Crendgrim »

[showif] should be [show_if].
UMC Story Images — Story images for your campaign!
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Using extradefines= to give players extra campaign optio

Post by UnwiseOwl »

It works well, and my code looks so much nicer now :D
A quick question, though. It's probably not very important, but does this mean that my text is all untranslatable, and if so, is there anything I can do about it?
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Using extradefines= to give players extra campaign optio

Post by zookeeper »

UnwiseOwl wrote:It works well, and my code looks so much nicer now :D
A quick question, though. It's probably not very important, but does this mean that my text is all untranslatable, and if so, is there anything I can do about it?
Well, you're currently doing it wrong: "message= _ {MESSAGE}" makes the string "{MESSAGE}" translatable, but obviously there's no such string. What you need is message={MESSAGE} and then use the underscore in front of the actual string you want to be translatable: for example {TALK Nym _"Hi."}.
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Using extradefines= to give players extra campaign optio

Post by UnwiseOwl »

I suspected that that was the case. Thanks, zookeeper.
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Using extradefines= to give players extra campaign optio

Post by UnwiseOwl »

I've done the above and embedded it in a prestart event for my first scenario, which seems to work well except that I would like it to go before the [story] tags, but if I place it before them the story tags don't seem to work. Can I either fix this or imitate [story] tags manually somehow?
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Using extradefines= to give players extra campaign optio

Post by Anonymissimus »

Even if you place a prestart event above the story tags in the scenario file both should work as usual, so i guess you're doing something wrong.
If a prestart event is already executed after the story tags, you could try using a preload event (with first_time_only=yes). I don't know whether it's executed before [story]. If not, it's not possible.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Using extradefines= to give players extra campaign optio

Post by zookeeper »

Naturally you can't display [message]s before the story screen.
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Using extradefines= to give players extra campaign optio

Post by UnwiseOwl »

There's no problem with having [story] tags inside other tags?
I currently have them nested in an [else] and it doesn't seem to work properly. Very possible that I have something else wrong, though.
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
User avatar
Crendgrim
Moderator Emeritus
Posts: 1328
Joined: October 15th, 2010, 10:39 am
Location: Germany

Re: Using extradefines= to give players extra campaign optio

Post by Crendgrim »

IntroWML wrote:The only other tags currently recognized within [story] and [part] are [if]/[then]/[else] and [switch]/[case]. These can be used to show parts conditionally on the values of variables.
IntroWML

So, you probably (if the wiki is correct, I never tried that myself) have to nest the [if]/[else] structures inside the [story] tag, not the other way around (I'm just noting this in case you aren't aware of it).
And no, as [story] seems not to be part of ActionWML, it probably won't work somewhere else.
UMC Story Images — Story images for your campaign!
Post Reply