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.
Re: ForestDragon's WML questions
Yes, that is part of cfg.
wml.get_child(cfg, "filter")
wml.get_child(cfg, "filter")
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
Thanks. Where should the code be put, though? Also, should the message be like wesnoth.message("unstore_unit:",cfg.variable,cfg.filter), or something else?
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
wesnoth.message takes 1 or 2 arguments, you can not give it 3.
Filter is not attribute, so cfg.filter doesnt give anything. You need to get filter child instead. You might need https://wiki.wesnoth.org/LuaWML/Misc#wesnoth.debug if you want to show filter table as string.
Filter is not attribute, so cfg.filter doesnt give anything. You need to get filter child instead. You might need https://wiki.wesnoth.org/LuaWML/Misc#wesnoth.debug if you want to show filter table as string.
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
where should I insert wesnoth.debug() into the following code?Ravana wrote: ↑June 26th, 2018, 12:15 pm wesnoth.message takes 1 or 2 arguments, you can not give it 3.
Filter is not attribute, so cfg.filter doesnt give anything. You need to get filter child instead. You might need https://wiki.wesnoth.org/LuaWML/Misc#wesnoth.debug if you want to show filter table as string.
Code: Select all
[event]
name=preload
[lua]
code=<<
local old = wesnoth.wml_actions.store_unit
function wesnoth.wml_actions.store_unit(cfg)
wesnoth.message("store_unit:",cfg.variable)
old(cfg)
end
local old = wesnoth.wml_actions.unstore_unit
function wesnoth.wml_actions.unstore_unit(cfg)
wesnoth.message("unstore_unit:",cfg.variable)
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
That code does not need it. It is used to format table as string, and cfg.variable already is string.
You might want wesnoth.message("unstore_unit:",wesnoth.debug(wml.get_child(cfg,"filter")))
You might want wesnoth.message("unstore_unit:",wesnoth.debug(wml.get_child(cfg,"filter")))
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
ok, but could you please post an a working example of an application of the wesnoth.debug() code, as reference?
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
Never used it, I implemented my own function to inspect tables https://github.com/ProditorMagnus/Oroci ... ctions.lua
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
Is it possible to instead do something like "wesnoth.message("store_unit:",cfg.variable.id)"?
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
No, you need to use get_child to get anything from subtag.
wml.get_child(cfg,"filter").id
wml.get_child(cfg,"filter").id
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
ok, but how do I write the result of the gotten wml child? (instead of cfg.x.y)
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
What you mean as result?
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
the child content, like ".id", for example.
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
wesnoth.message(wml.get_child(cfg,"filter").id)
- ForestDragon
- Posts: 1771
- Joined: March 6th, 2014, 1:32 pm
- Location: Ukraine
Re: ForestDragon's WML questions
ok, thanks.
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
another question on the topic: is it possible extract one of a list of values from a table like "filter" with the previous code? (with a list of possible values, like .id and.type, with one of the two being chosen if either was in the filter)
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