Clearing one specials id instead whole tag, but how to ?

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
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Clearing one specials id instead whole tag, but how to ?

Post by Eagle_11 »

{CLEAR_VARIABLE enchanted_refresh[$i].attack.specials.chance_to_hit } work, however cleans any [chance_to_hit] on that attack of the unit, i need to clean only enchanted.
{CLEAR_VARIABLE enchanted_refresh[$i].attack.specials.chance_to_hit.id.enchanted } does not have any effect. Ive tried putting enchanted in place of .id directly, didnt bring anything.
{VARIABLE enchanted_unit[$i].attack.specials.chance_to_hit.id enchanted} when giving the special gets done as such, why cant remove using similar ?
User avatar
Ravana
Forum Moderator
Posts: 2948
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Clearing one specials id instead whole tag, but how to ?

Post by Ravana »

Check enchanted_refresh[$i].attack[$j].specials.chance_to_hit[$k].id

Note that if you want to remove special by id, there is better way.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Clearing one specials id instead whole tag, but how to ?

Post by zookeeper »

Eagle_11 wrote: May 30th, 2018, 1:13 pm{CLEAR_VARIABLE enchanted_refresh[$i].attack.specials.chance_to_hit.id.enchanted } does not have any effect. Ive tried putting enchanted in place of .id directly, didnt bring anything.
There is no [id] tag containing either [enchanted] or enchanted=whatever, which are the things that code would try to clear. Your code says "clear the tag or key named enchanted from inside an [id] tag from inside the (first, if there are several) [chance_to_hit] tag from inside the [specials] tag from inside [...]", which of course describes a thing that doesn't exist.

You'd just need to iterate over all the chance_to_hit tags (which is what Ravana hints at), find the one(s) which have id=enchanted, and then clear them. But what you probably really want to do is utilize EffectWML and remove_specials=, likely via [modify_unit] or [object].
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: Clearing one specials id instead whole tag, but how to ?

Post by Eagle_11 »

Thank you both! I know of the effect wml, as have already used it elsewhere, but still wanted able to do it in this way too.
Ravana, what is that other better way you hinted, was it the EffectWML zookeeper mentioned ?
User avatar
Ravana
Forum Moderator
Posts: 2948
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Clearing one specials id instead whole tag, but how to ?

Post by Ravana »

Yes. Your original post wanted to only remove id, but if you want to remove entire special by id, then use remove_specials.
Post Reply