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

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

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

Post by Eagle_11 » May 30th, 2018, 1:13 pm

{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
Moderator
Posts: 1748
Joined: January 29th, 2012, 12:49 am
Location: Estonia

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

Post by Ravana » May 30th, 2018, 1:25 pm

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: 9713
Joined: September 11th, 2004, 10:40 pm
Location: Finland

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

Post by zookeeper » May 30th, 2018, 2:03 pm

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

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

Post by Eagle_11 » May 30th, 2018, 3:47 pm

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
Moderator
Posts: 1748
Joined: January 29th, 2012, 12:49 am
Location: Estonia

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

Post by Ravana » May 30th, 2018, 3:55 pm

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