Add result variable to [message] tag

If [message] includes one or more [option] choices, store the choice index in the result variable.
This commit is contained in:
Gregory A Lundberg 2016-08-12 21:40:01 -05:00
parent 8b87a29b18
commit f0ad540001
2 changed files with 14 additions and 0 deletions

View file

@ -18,6 +18,11 @@ Version 1.13.5+dev:
* Fix game map sometimes showing and buttons sometimes not rendered properly in story screen (bug #24553)
* Improved font rendering on Windows.
* WML Engine:
* New attributes for [message] with [option]
- Added variable= to [message]: if specified, gives variable name to receive the [option] index (1..n) selected
only used if any [option] appear
- Added value= to [option]: if specified, gives value to store in variable instead of index number, only used
if variable= appears in [message]
* New attributes for [role]:
- search_recall_list=yes|no|only(default yes) controls where to look
- reassign=yes|no(default yes) if no, check for a unit and do not assign to another

View file

@ -287,6 +287,7 @@ function wesnoth.wml_actions.message(cfg)
description = option.description,
image = option.image,
default = option.default,
value = option.value
}
if option.message then
if not option.label then
@ -391,6 +392,14 @@ function wesnoth.wml_actions.message(cfg)
return
end
if cfg.variable ~= nil then
if options[option_chosen].value == nil then
wesnoth.set_variable(cfg.variable, option_chosen)
else
wesnoth.set_variable(cfg.variable, options[option_chosen].value)
end
end
for i, cmd in ipairs(option_events[option_chosen]) do
local action = utils.handle_event_commands(cmd, "plain")
if action ~= "none" then break end