• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How can I clear an Ability variable?

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2013
Messages
1,105
There isn't really an ability type of variable, it's just an integer. However, if you want to set it to "No ability" you could use the action custom script and do set udg_abilityName = 0.

Why are you needing to set the ability to nothing though?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
There is no need to set a GUI ability variable to a no value as no matter what value it is set to it will use the same amount of storage space (no leak).

One can use a default value such as 0, or maybe another ability to signify an invalid value. However what value you choose is entirely up to you as long as it is not a valid type reference in the context of use.
 
Level 11
Joined
Jun 2, 2004
Messages
849
IIRC the "no ability" default for globals is 0. You can use a custom script "set udg_ability = 0" to nullify it. If you want to be 100% GUI you could just arbitrarily define an ability to be a "null" ability and just check against that.

Having a default "null" value is quite useful, depending on what you're doing. In my current map I have arrays of abilities that aren't always 100% full of valid abilities, and a null value tells me when I shouldn't actually add an ability to a unit.

An easy example of such a usage is a system where you can equip/unequip abilities; you may have, say, 7 slots per unit for abilities, and an "empty" slot (for when the player has yet to earn/purchase enough abilities, or is in the middle of switching them out) would be set to a null ability in the arrays/hashtables.
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
Sure. It seems as though you could just as easily use something like a boolean or integer and see if is the right value then add/don't add.

But as we've said it is possible to set it "no ability" if that is preferred.

If you want more direct assistance post your trigger(s) and allow us to examine.
 
Status
Not open for further replies.
Top