If you're asking how to store a unit in a WML variable from Lua, like
If you're asking how to find a unit based on the content of the ActionWML tag, like
Note that
[store_unit] does:Code:
local unit = wesnoth.units.find "unit_id" -- get the unit however you want, this example looks it up by its IDwml.variables["your.variable[2].path"] = unit.__cfg[message] does:Code:
function wesnoth.wml_actions.your_tag(cfg)local unit = wesnoth.units.find(cfg)[1] -- this assumes you want to take the first match – find returns all matching units as an array-- do stuff with unit hereend[message] is more complicated than that in order to handle the speaker= key, which isn't part of StandardUnitFilter. So, if you use the above example, you can't use speaker=. If you want, you can look at the implementation of the [message] tag in data/lua/wml/message.lua, but be warned that it is very complicated in order to handle a wide variety of situations.Statistics: Posted by Celtic_Minstrel — Today, 4:49 am