• 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.

[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,285
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