ForestDragon's WML questions
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.
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
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)
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
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)
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
Re: ForestDragon's WML questions
You can override wesnoth.wml_actions.* to log when tag is entered.
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
could you please be a bit more specific as to where this code should be put?
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
Re: ForestDragon's WML questions
In [lua], usually under preload event. It is also possible to add it in core lua files.
Example of one tag
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
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
debug.traceback might be useful too. https://github.com/ProditorMagnus/Oroci ... it.lua#L27
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
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: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 tagIf 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.Code: Select all
local old = wesnoth.wml_actions.harm_unit function wesnoth.wml_actions.harm_unit(cfg) wesnoth.message("harm_unit") old(cfg) end
debug.traceback might be useful too. https://github.com/ProditorMagnus/Oroci ... it.lua#L27
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]
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
Re: ForestDragon's WML questions
With [lua] it works as
[lua]
code=<<
code
>>
[/lua]
[lua]
code=<<
code
>>
[/lua]
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
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)
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
Re: ForestDragon's WML questions
Tags get their input as the first parameter - usually called cfg. So you would want to show cfg.variable. Lua string concatenation operator is
..
.- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
Could please explain the last part (the Lua string concatenation operator) a bit more in detail?
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
ok, thanks.Ravana wrote: ↑June 26th, 2018, 9:12 am Some old debugging code https://github.com/ProditorMagnus/Oroci ... #L122-L138
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
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?
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
Re: ForestDragon's WML questions
Not really, all wml is dumped to one virtual file before it is evaluated.
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
oh,ok. is at least possible to store a tag's [filter] values?
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic