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!
For the sake of GUI functioning, so that the entire script wasn't in Custom script, using a global variable that will act like a local in this case is also possible. Otherwise it might as well have been in Jass or vJass. But then again, I don't do GUI so I wouldn't know the proper method.
Edit: And it's just good practice to null a variable like this in this situation, had a local been used and that wasn't implicated, then it would have leaked. But all is well. I see your point ; )
Because you can use a Temporal Unit Variable to prevent calling over and over the same unit. In this trigger is just one aditional action... but still, if it can be improved, why not?
a temp variable slot isn't wasted, since you use it over and over and over to make all the triggers more effective.
// 2 Lines // 1 GetUnit()
Set Target = Target unit of ability being cast
Unit - Set mana of Target to (Mana of Target) x 0.75)
JASS:
// 1 Line // 2 GetUnit()
Unit - Set mana of (Target unit of ability being cast) to (Mana of (Target unit of ability being cast)) x 0.75)
In this case where the (Target Unit of Ability Being Cast) is just being used twice, it doesn't matter. But if you have more functions involving the same unit, using the variable is waaaaaayyy better.
// 2 Lines // 1 GetUnit()
Set Target = Target unit of ability being cast
Unit - Set mana of Target to (Mana of Target) x 0.75)
JASS:
// 1 Line // 2 GetUnit()
Unit - Set mana of (Target unit of ability being cast) to (Mana of (Target unit of ability being cast)) x 0.75)
In this case where the (Target Unit of Ability Being Cast) is just being used twice, it doesn't matter. But if you have more functions involving the same unit, using the variable is waaaaaayyy better.
Let me again clarify, the storage of the unit into a variable will cause only 1 GetUnit call. It's not only more efficient its a good coding practice. Since the global variable "udg_Target" is a temporal variable, you actually don't even need to null it, it will be recycling in the end after all.
I was kinda referring to everyone xD. There's a method to my madness. Most of it is proper coding practice but W/E. GUI has its own little qwerks, but the concept is the same. I hope it helps some people understand more optimum coding, I myself am personally always learning better and more efficient ways to code things. We are always learning as coders!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.