Quantcast
Channel: The Battle for Wesnoth Forums
Viewing all articles
Browse latest Browse all 2292

Lua Labs • Re: Another basic lua query

$
0
0
--1--

When you write config.filter, you're expecting WML like the following:

Code:

[ftest]filter=something[/ftest]
But the WML you've written is like the following:

Code:

[ftest][filter]id=whatever[/filter][/ftest]
So to get that in Lua, you use wml.get_child('filter'). See here for more info.

--2--

You seem to have left out the actual error message, but it's fairly obvious what's wrong here. When assigning to wml.array_variables.ftest, the right-hand side must be an array of WML tables. However, you've assigned an array of units instead. You can convert an array of units to an array of WML tables representing the units with the following code:

Code:

for i = 1, #units dounits[i] = units[i].__cfgend
I did look for the code for [store_unit] but couldn't find it - if I've missed it, please let me know where it's located.
The code for most ActionWML tags is located either in data/lua/wml-tags.lua or one of the files in data/lua/wml/. A few are located in other places – data/lua/wml-flow.lua or even in the C++ source code in game_events/action_wml.cpp.

Assuming the tag is implemented in Lua, you should be able to find a function called wml_actions.tag_name in one of the above files. I believe [store_unit] is in wml-tags.lua.

Statistics: Posted by Celtic_Minstrel — Today, 1:02 pm



Viewing all articles
Browse latest Browse all 2292

Trending Articles