Problem with switch

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
EnergiaX
Posts: 17
Joined: May 12th, 2018, 10:59 am

Problem with switch

Post by EnergiaX » May 20th, 2018, 3:15 pm

Hi,
I have problem witch [switch] [case] Wiki example https://wiki.wesnoth.org/ConditionalAct ... Bswitch.5D
I don't understand why don't work, no error is displayed. It just does not enter [switch], i try more times and debug witch message.

Code: Select all

#define Armor X Y
{VARIABLE ArmorName A}
	[item]
		x={X}
		y={Y}
		image=items/armor.png
    [/item]
	[event]
		name=moveto
		[filter]
			x={X}
			y={Y}
		[/filter]
		{VARIABLE_OP temp_rand_value rand (1,2)}
		[object]
			image=items/armor.png
			silent=yes
			[filter]
				x={X}
				y={Y}
			[/filter]
			[then]
				[unit_overlay]
					x={X}
					y={Y}
					image=overlays/arcane-icon.png
				[/unit_overlay]
				[remove_item]
					x,y={X},{Y}
				[/remove_item]
			[/then]
			[effect]
				apply_to=hitpoints
				increase=15
				increase_total=15
			[/effect]		
				[switch]
				variable=$temp_rand_value
					[case]
						value=1
						#ArmorName= _ "Arcane Armor"
						[effect]
							apply_to=resistance
							replace=false
							[resistance]
							arcane=-5
							[/resistance]
						[/effect]
					[/case]	
					[case]
						value=2
						#ArmorName= _ "Pierce Armor"
						[effect]
							apply_to=resistance
							replace=false
							[resistance]
							pierce=-5
							[/resistance]
						[/effect]
					[/case]	
					[/switch]
					#name=$ArmorName
		[/object]
	[/event]
#enddef
Armor is it, +15 hp it work. When I use message =$temp_rand_value, i see 1 or 2. When i delate switch and case, I give resistance bonuses. Can anyone help?

User avatar
Ravana
Moderator
Posts: 1888
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Problem with switch

Post by Ravana » May 20th, 2018, 3:41 pm

[switch] is not subtag of [object].

User avatar
Pentarctagon
Forum Administrator
Posts: 3631
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Problem with switch

Post by Pentarctagon » May 20th, 2018, 3:43 pm

I'd assume you'd need to put the [switch] inside of the [then].
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

EnergiaX
Posts: 17
Joined: May 12th, 2018, 10:59 am

Re: Problem with switch

Post by EnergiaX » May 20th, 2018, 6:51 pm

But when I put the [switch] inside of the [then] i have error:
<invalid WML found> [effect] not supprted
In game (the game turns on, the error is displayed as it tries to take an artifact)

meaby [effect] it can not be inside [then]

Somewhere I can find information about what tag can be in what tag?

Caladbolg
Posts: 157
Joined: January 1st, 2016, 4:40 pm
Location: Hopelessly trapped within the Submachine

Re: Problem with switch

Post by Caladbolg » May 20th, 2018, 7:02 pm

You might have to do some digging around, but this is a good starting point:
https://wiki.wesnoth.org/ActionWML
It says that ConditionalActionsWML (which [switch] is a part of) belongs to ActionWML, and you have a list of cases where it can be used; [object] is not one of them.

User avatar
Ravana
Moderator
Posts: 1888
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Problem with switch

Post by Ravana » May 20th, 2018, 7:28 pm

Inside [case] goes ActionWML, and [effect] is not part of ActionWML. Possible solutions for your use are:
[insert_tag],
[lua],
multiple [object]s.

I suggest last one.

EnergiaX
Posts: 17
Joined: May 12th, 2018, 10:59 am

Re: Problem with switch

Post by EnergiaX » May 21st, 2018, 11:11 am

Ok, thx.
Making a few objects will be the most easy.
[topic can close]

Post Reply