• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

how do i connect a variable to a unit?

Not open for further replies.
Level 9
Jan 14, 2008
take this trigger as example

- unit of unit type "axeman" is trained
- get unit of unittype "houseX" within 1000 range of triggering unit
and do action:
set variableX [1] = variableX[1] + 1

now lets assume i have a shitload of houses. is there no way to have a function determine wich variable corresponds to wich house?

i dont want to have one million "if/then"else's" ...

so how can i assign variableX to house1
and variableXX to house2 and so on ... ???

is there no way to recall a variable by converting its name to a string?
why not? that would be such an useful function.

any help or input appreciate.
Level 11
Feb 16, 2009
It like this:
Make one variable (A integer) and set its default value to 1
Everytime you want to attach a unit, set the untis custom value to the integer.
then add 1 to the integer
Whenever you want to acces the variable, just use the custom value of the unit as index
Level 9
Jan 14, 2008
i need one variable (with 20 arrays each) per unit.

is your method able to handle that? because if it is i have not understood SHIT
of what you were trying to explain. maybe you could elaborate further?
  • Trigger
  • Events
    • Unit - A unit finishes training a unit
  • Conditions
    • ((Unit-type) of (Trained unit)) Equal to Axeman
  • Actions
    • Set Temp_point = (Position of (Triggering unit))
    • Set Temp_Group = (Units within 1000.00 of (Temp_point) matching ((Unit-type of (Matching unit) Equal to HouseX)
    • Unit Group - Pick up every unit in (Temp_Group) and do (Actions)
      • Loop - Actions
        • For each (IntegerA) from 1 to (Number of units in (Temp_Group)), do Actions
          • Loop - Actions
            • Set Variable[Integer A] = Variable[Integer A] + 1
    • Custom script: call RemoveLocation (udg_Temp_point)
    • Custom script: call DestroyGroup (udg_Temp_Group)
Please, watch your language. :/
Not open for further replies.