• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Spell] Variables

Status
Not open for further replies.
The Variables generated by using the GUI-Variable-Editor are Global. They can be read/written from any Trigger. But have always the last written value.

Except you define them local for a trigger.
By using custom skript.
  • Custom script: local integer udg_Int
In this case the variable can only be read or written in this trigger run only.
Have to be the first line of Code in a Trigger.
 
Last edited:
Level 6
Joined
Sep 13, 2013
Messages
155
There is an easy way to make local unit and unit group variables in GUI:

For Unit:

  • Custom script: local unit udg_UnitVariable
  • Set UnitVariable = (your unit)
  • -------- Your desired triggers and stuff --------
  • Custom script: set udg_UnitVariable = null
For Unit Group:

  • Custom script: local group udg_UnitGroupVar = CreateGroup()
  • Set UnitGroupVar = (your unit group)
  • -------- Your desired triggers and stuff --------
  • Custom script: call DestroyGroup(udg_UnitGroupVar)
  • Custom script: set udg_UnitGroupVar = null
This may help making MUI spells.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,207
guys can a variable be used multiple times in different triggers with different uses
It can be used in multiple triggers but you need to be very careful that uses do not overlap. For example 2 triggers can use it as a temporary storage location for a unit, location, group etc but you need to make sure that only 1 instance of both triggers can be running at the same time. Calling some actions will cause other triggers to fire and interrupt the current trigger for example DamageUnit will cause damage event triggers to fire and interrupt the calling thread. In such cases you need to be careful that global variable usage does not overlap otherwise you might lose track of some values resulting in leaks of buggy behaviour.
 
Status
Not open for further replies.
Top