Tutorial improvements - WML questions

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
andris
Posts: 5
Joined: June 20th, 2018, 5:48 am

Tutorial improvements - WML questions

Post by andris » June 21st, 2018, 10:40 am

Hi all,

Edit: pull request created based on the discussion below: https://github.com/wesnoth/wesnoth/pull/3281 - thanks for everyone involved!

I'm brand new to WML, spent a few hours on fixing some tutorial issues but a minor one is yet to be resolved.

In short: is there a way to make the village capture messages appear in tutorial only AFTER a village is captured?

Right now when you move Konrad to one of the villages, the message states "It now flies your colors and has been added to your total village count", yet the changes (flag and counter increment) happens only after you close the info messages. It would be natural the other way around. Simple fix could be to change the wording to 'will be added' - but that would break all translations, I'd be happier with the programmatic solution.

I think this happens because the [capture] and [moveto] are fired before the "administration" happens. Is there a way to schedule a delayed event perhaps, or any other way to get an event after the village is really in our hands?

Some other problems I hit during the translation of the tutorial, and tried to figure out myself:
#1584 tutorial: getting stuck sometimes, have to undo turn or reload
#3039 Tutorial - Moves are depleted, but can't end turn

(Implemented these already, will try to create proper pull requests:
* do not stuck next to Delfador without MP and without undo, away from the quintain (reorganized the summon event, changed Delfador's position)
* display an undo message when we can't reach the target with our movement points ([find_path], [store_location] and friends))

Thanks,
Andris
Last edited by andris on June 24th, 2018, 6:36 pm, edited 3 times in total.

User avatar
Ravana
Moderator
Posts: 1874
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Tutorial improvements - WML questions

Post by Ravana » June 21st, 2018, 10:49 am

Try out [redraw] before [message], it is possible that change has already happened, just not visible.

andris
Posts: 5
Joined: June 20th, 2018, 5:48 am

Re: Tutorial improvements - WML questions

Post by andris » June 21st, 2018, 11:59 am

Ravana wrote:
June 21st, 2018, 10:49 am
Try out [redraw] before [message], it is possible that change has already happened, just not visible.
I added a

Code: Select all

[redraw]
[/redraw]
before the [message] but it did not change anything. Will give it another try in the evening but I think it's not fixing the issue.

enclave
Posts: 887
Joined: December 15th, 2007, 8:52 am

Re: Tutorial improvements - WML questions

Post by enclave » June 21st, 2018, 1:39 pm

andris wrote:
June 21st, 2018, 11:59 am

Code: Select all

[redraw]
[/redraw]
before the [message] but it did not change anything. Will give it another try in the evening but I think it's not fixing the issue.
Hi Andris, a lot of things can be coded differently to achieve what you want if you are in power to change your code, so there is a chance that we can fix it. Could you copy paste here your event with message? I want to see full details if possible.

andris
Posts: 5
Joined: June 20th, 2018, 5:48 am

Re: Tutorial improvements - WML questions

Post by andris » June 21st, 2018, 1:47 pm

enclave wrote:
June 21st, 2018, 1:39 pm
Hi Andris, a lot of things can be coded differently to achieve what you want if you are in power to change your code, so there is a chance that we can fix it. Could you copy paste here your event with message? I want to see full details if possible.
Here's the capture event - you can see it in the unmodified Steam version also:

https://github.com/wesnoth/wesnoth/blob ... 1.cfg#L476

It is the second turn in the tutorial, when after attacking the quintain you need to be healed in a village and for that you should occupy one.
You move in, the message says number of villages incremented but that remains 0 until you close the message, when it really increments.

Thanks!

enclave
Posts: 887
Joined: December 15th, 2007, 8:52 am

Re: Tutorial improvements - WML questions

Post by enclave » June 21st, 2018, 7:00 pm

andris wrote:
June 21st, 2018, 1:47 pm
It is the second turn in the tutorial, when after attacking the quintain you need to be healed in a village and for that you should occupy one.
You move in, the message says number of villages incremented but that remains 0 until you close the message, when it really increments.
Yeah I confirm I see the same bahavior, I created separate add-on to test it.

To say more I have tried to modify the code and found what exactly causes the problem,
It is speaker=narrator
The code without speaker=narrator updates the flag and the village count first, and then displays the message, while the code with speaker=narrator will first display the message and only then update the village count and recolor the flag..
Examples:

Code: Select all

[event]
name=capture
first_time_only=false
[message]
speaker=narrator
caption= _ "Villages"
image=wesnoth-icon.png
message="this village belong to me"
[/message]
[/event]
will display message first, before updating the village count and flag

Code: Select all

[event]
name=capture
first_time_only=false
[message]
caption= _ "Villages"
image=wesnoth-icon.png
message="this village belong to me"
[/message]
[/event]
will update the village count and recolor the flag first, and then display the message.


So what you could do as a developer of campaign to change it is to either delete the "speaker=narrator" (the easiest and the only possible way)
Or add

Code: Select all

[delay]
time=0
[/delay]
before [message] to recolor the flag.
There seems to be no way to update the village count, even manually with lua.theme.items, the message always happens first.

As for the problem itself, the bahavior is clearly a bug to me.. so feel free to report it using wesnoth official best way to report bugs with its bugtracker https://github.com/wesnoth/wesnoth/issues/ I probably dont remember my password to login there :) gl hf

andris
Posts: 5
Joined: June 20th, 2018, 5:48 am

Re: Tutorial improvements - WML questions

Post by andris » June 21st, 2018, 9:44 pm

You both have helped a lot in resolving the issue, thank you!

Repeated my tests, [redraw] has the same effect the [delay] has: the flag at least appears, but the village count is not incremented.
So I also performed trials and noticed that if I change the speaker from narrator to Delfador, that also fixes the problem, the flag and the village count are both proper without any extra hacks.

Started searching for the reason of this strange behaviour, and maybe found the actual fix by applying the most advanced copy-paste technologies. :)

In https://github.com/wesnoth/wesnoth/blob ... e.lua#L372 firing a redraw at the end of the narrator case makes it perfect:

Code: Select all

	elseif speaker == "narrator" then
		-- Narrator, so deselect units
		wesnoth.deselect_hex()
		-- The speaker is expected to be either nil or a unit later
		speaker = nil
		wesnoth.fire("redraw")   -- this line fixes the problem
	else
There you can see my very first lua comment as well, please appreciate it!
If somebody is eager to apply this one liner fix, feel free to do so, otherwise at the weekend I'll learn how to create a pull request.

Thanks again for the quick help, both responses were very well targeted!

andris
Posts: 5
Joined: June 20th, 2018, 5:48 am

Re: Tutorial improvements - WML questions

Post by andris » June 23rd, 2018, 7:17 am

Second question: should I target the master or the 1.14 branch with my pull request?

Third question: as I mentioned, I have some changes for the tutorial cfg as well. In that case which branch is preferred? (I'd be happy with 1.14 for earlier release, but as I never made any pull request for Wesnoth probably my happiness matters the less in this case. :) )

Edit: I read https://wiki.wesnoth.org/Git_for_Wesnot ... ll_request and it suggests master, but it also refers to gna.org bug tracker that is not available for me so I think that link is a bit outdated and maybe the frequent Steam releases changed the preferred branch.

User avatar
Pentarctagon
Forum Administrator
Posts: 3572
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Tutorial improvements - WML questions

Post by Pentarctagon » June 23rd, 2018, 7:35 am

andris wrote:
June 23rd, 2018, 7:17 am
Second question: should I target the master or the 1.14 branch with my pull request?
I'd suggest 1.14 since master is not currently in the best state, but fixes like this will almost always be added to both branches anyway, so ultimately it's up to you.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

Post Reply