ForestDragon's 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
User avatar
ForestDragon
Forum Regular
Posts: 1494
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 18th, 2018, 8:46 am

Hello everyone, another WML question: is it possible to edit the campaign laurel type mid-campaign? (Not having a difficulty choice at the start, but manually changing it to the golden type via an event). My intended application for this is an in-addon achivement system (the laurel type changing when copleting a specific achievement)
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
ForestDragon
Forum Regular
Posts: 1494
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 25th, 2018, 5:20 pm

Yet another WML question: is it possible, using tools like wmlint or the like, to view which events/tags are being triggered while in-game? (so that finding bugs is a bit less of a pain in the rear end)
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

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

Re: ForestDragon's WML questions

Post by Ravana » June 25th, 2018, 6:16 pm

You can override wesnoth.wml_actions.* to log when tag is entered.

User avatar
ForestDragon
Forum Regular
Posts: 1494
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 25th, 2018, 6:44 pm

Ravana wrote:
June 25th, 2018, 6:16 pm
You can override wesnoth.wml_actions.* to log when tag is entered.
could you please be a bit more specific as to where this code should be put?
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

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

Re: ForestDragon's WML questions

Post by Ravana » June 25th, 2018, 7:20 pm

In [lua], usually under preload event. It is also possible to add it in core lua files.

Example of one tag

Code: Select all

local old = wesnoth.wml_actions.harm_unit
function wesnoth.wml_actions.harm_unit(cfg)
    wesnoth.message("harm_unit")
    old(cfg)
end
If you need that for many tags, would be useful do create array of tags you want to log and then iterate over them to modify them.

debug.traceback might be useful too. https://github.com/ProditorMagnus/Oroci ... it.lua#L27

User avatar
ForestDragon
Forum Regular
Posts: 1494
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 26th, 2018, 8:05 am

Ravana wrote:
June 25th, 2018, 7:20 pm
In [lua], usually under preload event. It is also possible to add it in core lua files.

Example of one tag

Code: Select all

local old = wesnoth.wml_actions.harm_unit
function wesnoth.wml_actions.harm_unit(cfg)
    wesnoth.message("harm_unit")
    old(cfg)
end
If you need that for many tags, would be useful do create array of tags you want to log and then iterate over them to modify them.

debug.traceback might be useful too. https://github.com/ProditorMagnus/Oroci ... it.lua#L27
Thanks, this is exactly what I needed. However, there seems to be a syntax error in the one-tag code you sent. Here's the slightly edited version of the code/error message:

Code: Select all

    [event]
        name=preload
	[lua]
local old = wesnoth.wml_actions.unstore_unit
function wesnoth.wml_actions.unstore_unit(cfg)#this is the line 23 mentioned in the error message
    wesnoth.message("unstore_unit")
    old(cfg)
end
        [/lua]
    [/event]
lua_error_message.png
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

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

Re: ForestDragon's WML questions

Post by Ravana » June 26th, 2018, 8:44 am

With [lua] it works as

[lua]
code=<<
code
>>
[/lua]

User avatar
ForestDragon
Forum Regular
Posts: 1494
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 26th, 2018, 8:47 am

Ravana wrote:
June 26th, 2018, 8:44 am
With [lua] it works as

[lua]
code=<<
code
>>
[/lua]
works now, thanks. btw, is it possible to see which variable was unstored in the tag? (putting something like $wesnoth.wml_actions.unstore_unit.variable| in the log message)
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

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

Re: ForestDragon's WML questions

Post by Ravana » June 26th, 2018, 8:57 am

Tags get their input as the first parameter - usually called cfg. So you would want to show cfg.variable. Lua string concatenation operator is ...

User avatar
ForestDragon
Forum Regular
Posts: 1494
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 26th, 2018, 9:01 am

Ravana wrote:
June 26th, 2018, 8:57 am
Tags get their input as the first parameter - usually called cfg. So you would want to show cfg.variable. Lua string concatenation operator is ...
Could please explain the last part (the Lua string concatenation operator) a bit more in detail?
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"


User avatar
ForestDragon
Forum Regular
Posts: 1494
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 26th, 2018, 9:16 am

Ravana wrote:
June 26th, 2018, 9:12 am
Some old debugging code https://github.com/ProditorMagnus/Oroci ... #L122-L138
ok, thanks.
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
ForestDragon
Forum Regular
Posts: 1494
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 26th, 2018, 11:11 am

yet another small question regarding the debugging code: is it possible to store the location of the tag (file or line) as an output of the message?
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

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

Re: ForestDragon's WML questions

Post by Ravana » June 26th, 2018, 11:14 am

Not really, all wml is dumped to one virtual file before it is evaluated.

User avatar
ForestDragon
Forum Regular
Posts: 1494
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 26th, 2018, 11:48 am

Ravana wrote:
June 26th, 2018, 11:14 am
Not really, all wml is dumped to one virtual file before it is evaluated.
oh,ok. is at least possible to store a tag's [filter] values?
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

Post Reply