library myStruct
globals
endglobals
struct myStruct
unit u
static method create takes unit u returns thistype
local thistype this = thistype.allocate()
set this.u = u
return this
endmethod
//put any functions here that each unit has
//i.e. your code goes here
endstruct
endlibrary
All 3 have their purposes. Hashtables are good for mapping arbitrary values such as to units and things. Arrays are good for creating allocable data structures. Locals are used to avoid clogging the map with excessive arrays and allow nested code.
Generally arrays should be used for bulk data as they are fastest. Hashtables should be used for efficient lookup of mappings such as an index on a unit or a timer. Locals generally have nothing to do with MUI and are more a useful scripting tool.
Locals are related to MUI. Example:
Unit starts the effect of an ability
Set Caster = Casting Unit
Wait 5 seconds
Kill Caster
^ Not MUI
Unit starts the effect of an ability
local unit caster = Casting Unit
Wait 5 seconds
call KillUnit(caster)
^ MUI
not true. Or bad example at least.
- Untitled Trigger 001
- Events
- Unit - A unit Starts the effect of an ability
- Conditions
- Actions
- Wait 5.00 seconds
- Unit - Kill (Triggering unit)
both are MUI.
- Untitled Trigger 002
- Events
- Unit - A unit Starts the effect of an ability
- Conditions
- Actions
- Custom script: local unit udg_caster
- Set caster = (Triggering unit)
- Wait 5.00 seconds
- Unit - Kill caster