Store a variable using [option] in [message]

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Nyanyanyan
Posts: 69
Joined: May 11th, 2018, 10:40 pm

Store a variable using [option] in [message]

Post by Nyanyanyan »

I'm trying to allow a player to hand over gold to a unit which can then in turn hand that gold over to another player.

For that I'm using a right click menu prompt which contains the following code:

Code: Select all

				[store_side]
				side=$side_number
				variable=goldsendsidevar
				[/store_side]
				[message]
				speaker=unit
				message="How much Gold do you want to give to the Messenger?"
				side_for=$side_number
				wait_description="The turn player is reading or writing a message."
				[option]
				message="10 Gold"
				value=10
				[show_if]
				[variable]
				name=goldsendsidevar.gold
				greater_than_equal_to=10
				[/variable]
				[/show_if]
				[command]
					[gold]
						side=$side_number
						amount=-10
					[/gold]
				[/command]
				[/option]
				variable=goldinputvariable
				[command]
				[modify_unit]
					[filter]
						x,y=$x1,$y1
					[/filter]
					[variables]
						goldcarryvar=$goldinputvariable
					[/variables]
				[/modify_unit]
				{CLEAR_VARIABLE goldinputvariable}
				{CLEAR_VARIABLE goldsendsidevar}
				[/command]
				[/message]
This should theoretically allow a player to store the variable goldcarryvar inside the unit that is clicked on and give it the value 10.

Problem is, that's not what's happening. It simply doesn't store anything (checking with :inspect), but the player still loses the gold, meaning the command is firing as intended.

I tried putting the line
variable=goldinputvariable
inside the [option] tag, but that didn't work either.

Any help is appreciated.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
User avatar
Pentarctagon
Project Manager
Posts: 4646
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Store a variable using [option] in [message]

Post by Pentarctagon »

I don't believe that [command] is a valid subtag of [message].
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Helmet
Posts: 331
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Store a variable using [option] in [message]

Post by Helmet »

My campaign has command in a message and it works.

Code: Select all

					[message]
						speaker=narrator
						message= _ "Choose now:"	 		
						[option]
							message= _ "HARD"    	 		
							[command]
								[set_variable]
									name=skeletal_hand_variant
									value=no				
								[/set_variable]					
							[/command]
						[/option]
#						etc.
Well...I guess it works. I'm still playtesting. But I think it works.
User avatar
Pentarctagon
Project Manager
Posts: 4646
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Store a variable using [option] in [message]

Post by Pentarctagon »

[message][option][command] is intended - just [message][command] isn't.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Nyanyanyan
Posts: 69
Joined: May 11th, 2018, 10:40 pm

Re: Store a variable using [option] in [message]

Post by Nyanyanyan »

Huh, you're right. Putting the the [command] tag inside the [option] tag works as intended.
Thanks.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
Post Reply