URL:
<http://gna.org/bugs/?24288>
Summary: WML formulas evaluated too soon
Project: Battle for Wesnoth
Submitted by: pentarctag0n
Submitted on: Thu 07 Jan 2016 01:06:16 AM UTC
Category: Bug
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: WML
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 1.13.2+dev
Operating System: Linux Mint
_______________________________________________________
Details:
When there are multiple nested [command] blocks, WMl formulas are evaluated
before the variable being used in the formula exists. This causes the
following error to appear in the log:
error engine: Formula in WML string cannot be evaluated due to Illegal unary
operator: '+'
--> "+ "
however there is no actual error.
When the below code is run:
[event]
name="start"
[set_menu_item]
id="test"
description="test"
[command]
[message]
speaker="narrator"
message=""
[option]
label="1a"
[command]
[message]
speaker="narrator"
message=""
[option]
label="1b"
[command]
[message]
speaker="narrator"
message=""
[option]
label="1c"
[command]
[set_variable]
name=test1
value=1
[/set_variable]
[set_variable]
name=test2
value="$($test1+1)"
[/set_variable]
[message]
speaker="narrator"
message="$test2"
[/message]
{CLEAR_VARIABLE test1}
{CLEAR_VARIABLE test2}
[/command]
[/option]
[/message]
[/command]
[/option]
[/message]
[/command]
[/option]
[option]
label="2a"
[command]
[message]
speaker="narrator"
message=""
[option]
label="2b"
[command]
[message]
speaker="narrator"
message=""
[option]
label="2c"
[command]
[/command]
[/option]
[/message]
[/command]
[/option]
[/message]
[/command]
[/option]
[/message]
[/command]
[/set_menu_item]
[/event]
the above error is written to the log when the menu is opened and when the
options "1a" and "1b" are chosen. Selecting the option "2c" does not result
in the error being written to the log and the message correctly displays "2".
Selecting options "2a", "2b", and "2c" also does not result in the error being
written to the log.
What appears to me to be happening is that the formula is being evaluated by
each [command] tag, even though the formula won't actually be run until the
innermost [command]. Since the innermost [command] is also where the variable
being used in the formula is created, when the outer [command]s evaluate the
formula "$($test1+1)" they see "$(+1)" rather than "$(1+1)". This is backed
up by the fact that using the new default value syntax to instead have the
formula be "$($test1?0|+1)" results in the error not appearing in the log when
the menu is opened or the options "1a" and "1b" are chosen.
_______________________________________________________
Reply to this item at:
<http://gna.org/bugs/?24288>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs