Jump to content

Talk:ReferenceWMLDump: Difference between revisions

From The Battle for Wesnoth Wiki
Kernigh (talk | contribs)
I suggest that "$foo_$b" was not a valid complex substitution.
Kernigh (talk | contribs)
m Oops, I misformated my code. I will fix that now.
Line 25: Line 25:
: Further, the following example passes wesnoth 1.2.5, and at least demonstrates that the [allow_recruit]type= key permits complex substitution:
: Further, the following example passes wesnoth 1.2.5, and at least demonstrates that the [allow_recruit]type= key permits complex substitution:


# works in 1.2.5
# works in 1.2.5
[event]
[event]
name=start
name=start
{VARIABLE title "Sharpshooter"}
{VARIABLE title "Sharpshooter"}
{VARIABLE name title}
{VARIABLE name title}
[allow_recruit]
[allow_recruit]
type="Elvish $$name||"
type="Elvish $$name||"
side=1
side=1
[/allow_recruit]
[/allow_recruit]
[/event]
[/event]


: When I made a copy of 2p - Blitz with this event, side 1 was able to recruit Elvish Sharpshooters.
: When I made a copy of 2p - Blitz with this event, side 1 was able to recruit Elvish Sharpshooters.
Line 40: Line 40:
: To show why your test failed, I suggest that "$foo_$b" is not a valid complex suggestion. (I do not know why "$foo_$b" does not work; maybe there is a bug in 1.2.5, or I misunderstand how complex substitution works.) The wiki page claims that [message]message= allows complex substitution, so I extended your example to be:
: To show why your test failed, I suggest that "$foo_$b" is not a valid complex suggestion. (I do not know why "$foo_$b" does not work; maybe there is a bug in 1.2.5, or I misunderstand how complex substitution works.) The wiki page claims that [message]message= allows complex substitution, so I extended your example to be:


{VARIABLE foo_bar 42}
{VARIABLE foo_bar 42}
{VARIABLE b bar}
{VARIABLE b bar}
[gold]
[gold]
side=2
side=2
amount=$foo_$b
amount=$foo_$b
# broken in 1.2.5
# broken in 1.2.5
[/gold]
[/gold]
 
[message]
[message]
speaker=narrator
speaker=narrator
message=$foo_$b
message=$foo_$b
# broken in 1.2.5
# broken in 1.2.5
[/message]
[/message]


: When I tested this, side 2 failed to gain 42 gold, and the message box can up with an empty message! --[[User:Kernigh|Kernigh]] 16:35, 15 July 2007 (CEST)
: When I tested this, side 2 failed to gain 42 gold, and the message box can up with an empty message! --[[User:Kernigh|Kernigh]] 16:35, 15 July 2007 (CEST)

Revision as of 14:35, 15 July 2007

Kernigh wrote:

Since Wesnoth 1.1.5, all simple substitution was eliminated in favor of complex substitution, which is more versatile.

There is no source for this claim, and my tests contradict it: In wesnoth 1.2.5, the WML snippet

			{VARIABLE foo_bar 42}
			{VARIABLE b bar}
			[gold]
				side=1
				amount=$foo_$b
			[/gold]

does nothing, but

			{VARIABLE foo_bar 42}
			{VARIABLE b bar}
			{VARIABLE_OP temp format $foo_$b}
			[gold]
				side=1
				amount=$temp
			[/gold]

adds 42 gold to side 1. I have therefore reverted the edit. Please only change the content of this page if you are sure you are right.

Meriton 15:25, 15 July 2007 (CEST)

In the source file wesnoth-1.2.5/changelog, under the section for "Wesnoth 1.1.5", it states, "all [event] tags shall perform complex substitution".
Further, the following example passes wesnoth 1.2.5, and at least demonstrates that the [allow_recruit]type= key permits complex substitution:
			# works in 1.2.5
			[event]
				name=start
				{VARIABLE title "Sharpshooter"}
				{VARIABLE name title}
				[allow_recruit]
					type="Elvish $$name||"
					side=1
				[/allow_recruit]
			[/event]
When I made a copy of 2p - Blitz with this event, side 1 was able to recruit Elvish Sharpshooters.
To show why your test failed, I suggest that "$foo_$b" is not a valid complex suggestion. (I do not know why "$foo_$b" does not work; maybe there is a bug in 1.2.5, or I misunderstand how complex substitution works.) The wiki page claims that [message]message= allows complex substitution, so I extended your example to be:
			{VARIABLE foo_bar 42}
			{VARIABLE b bar}
			[gold]
				side=2
				amount=$foo_$b
				# broken in 1.2.5
			[/gold]

			[message]
				speaker=narrator
				message=$foo_$b
				# broken in 1.2.5
			[/message]
When I tested this, side 2 failed to gain 42 gold, and the message box can up with an empty message! --Kernigh 16:35, 15 July 2007 (CEST)