• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Solved] Set variable to index of array

Status
Not open for further replies.
Level 8
Joined
Jun 1, 2009
Messages
137
Any chance to set a variable to index from Unit[index] array?
Custom value ofc is occupied by another functions

  • example
    • Events
      • Unit - A unit enters A00 <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to Spawn_Hero_Unit[1]
        • Then - Actions
          • Set VariableSet Chosen_Int = (Chosen_Int + 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to Spawn_Hero_Unit[2]
        • Then - Actions
          • Set VariableSet Chosen_Int = (Chosen_Int + 2)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to Spawn_Hero_Unit[3]
        • Then - Actions
          • Set VariableSet Chosen_Int = (Chosen_Int + 3)
        • Else - Actions
I want to set Chosen_Int + index directly, if it even possible. Instead of hundreds of strings make the only one.
 
Just create an integer variable that counts the max of Spawn_Hero_Unit then do this :
  • Trigger
    • Events
      • Unit - A unit enters Region 001 <gen>
    • Conditions
    • Actions
      • For each (Integer A) from 1 to MaxSpawnHeroUnit, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to Spawn_Hero_Unit[(Integer A)]
            • Then - Actions
              • Set VariableSet Chosen_Int = (Chosen_Int + (Integer A))
            • Else - Actions
 
Status
Not open for further replies.
Back
Top