Settings variables for looped actions

N582114

New Member
Reaction score
2
Is it possible to add each of these visibility modifiers to its own variable?

Trigger:
  • For each (Integer A) from 1 to 8, do (Actions)
    • Loop - Actions
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectiona <gen>
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectionb <gen>
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectionc <gen>
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectiond <gen>

I want to be able to destroy them in the future.
 

jig7c

Stop reading me...-statement
Reaction score
123
Trigger:
  • For each (Integer A) from 1 to 8, do (Actions)
    • Loop - Actions
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectiona <gen>
      • Set Visibility[Integer A] = Last created visibility modifier
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectionb <gen>
      • Set Visibility[Integer A] = Last created visibility modifier
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectionc <gen>
      • Set Visibility[Integer A] = Last created visibility modifier
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectiond <gen>
      • Set Visibility[Integer A] = Last created visibility modifier


selectiona = 1
selectionb = 2
....
 

N582114

New Member
Reaction score
2
+rep, but you should note that using it like that will override different visibility triggers. They're all different.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
you should better use something like this:
Trigger:
  • For each (Integer A) from 1 to 8, do (Actions)
    • Loop - Actions
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectiona <gen>
      • Set Visibility[1 + (Integer A * 4)] = Last created visibility modifier
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectionb <gen>
      • Set Visibility[2 + (Integer A * 4)] = Last created visibility modifier
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectionc <gen>
      • Set Visibility[3 + (Integer A * 4)] = Last created visibility modifier
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectiond <gen>
      • Set Visibility[4 + (Integer A * 4)] = Last created visibility modifier

this is a virtual 2 dimensional array.

in the first loop (IntegerA is equal to 1) it will use Visibility[5],[6],[7] and [8] when IntegerA is equal to 2 Visibility[9],[10],[11] and [12] are used, and so on and so on.
 

jig7c

Stop reading me...-statement
Reaction score
123
so what your saying Accname, is that for Player 1, it'll use Visibility [5][6][7][8] variables.. and then for Player 2, it'll use [9][10][11][12]... and so on.. right?
 

Corleone

New Member
Reaction score
44
You could change the "Visibility[1+(IntegerA*4)]" into "Visibility[1+((IntegerA-1)*4)", so that your array starts at [1] instead of [5].

This leads to a smaller array.
 

N582114

New Member
Reaction score
2
I followed your advice and tried to destroy the visibility modifiers. It doesn't work however. I might of numbered the Integer A loop on the destruction trigger wrong.

Trigger:
  • For each (Integer A) from 1 to 8, do (Actions)
    • Loop - Actions
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectiona <gen>
      • Set herovisiblity[(1 + (((Integer A) - 1) x 4))] = (Last created visibility modifier)
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectionb <gen>
      • Set herovisiblity[(1 + (((Integer A) - 1) x 4))] = (Last created visibility modifier)
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectionc <gen>
      • Set herovisiblity[(1 + (((Integer A) - 1) x 4))] = (Last created visibility modifier)
      • Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across Selectiond <gen>
      • Set herovisiblity[(1 + (((Integer A) - 1) x 4))] = (Last created visibility modifier)


Destroying the modifiers:

Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Player number of (Owner of (Buying unit))) Equal to 1
    • Then - Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Visibility - Destroy herovisiblity[(Integer A)]
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player number of (Owner of (Buying unit))) Equal to 2
        • Then - Actions
          • For each (Integer A) from 5 to 9, do (Actions)
            • Loop - Actions
              • Visibility - Destroy herovisiblity[(Integer A)]
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player number of (Owner of (Buying unit))) Equal to 3
            • Then - Actions
              • For each (Integer A) from 10 to 14, do (Actions)
                • Loop - Actions
                  • Visibility - Destroy herovisiblity[(Integer A)]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Player number of (Owner of (Buying unit))) Equal to 4
                • Then - Actions
                  • For each (Integer A) from 15 to 19, do (Actions)
                    • Loop - Actions
                      • Visibility - Destroy herovisiblity[(Integer A)]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Player number of (Owner of (Buying unit))) Equal to 5
                    • Then - Actions
                      • For each (Integer A) from 20 to 24, do (Actions)
                        • Loop - Actions
                          • Visibility - Destroy herovisiblity[(Integer A)]
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Player number of (Owner of (Buying unit))) Equal to 6
                        • Then - Actions
                          • For each (Integer A) from 25 to 29, do (Actions)
                            • Loop - Actions
                              • Visibility - Destroy herovisiblity[(Integer A)]
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Player number of (Owner of (Buying unit))) Equal to 7
                            • Then - Actions
                              • For each (Integer A) from 30 to 34, do (Actions)
                                • Loop - Actions
                                  • Visibility - Destroy herovisiblity[(Integer A)]
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Player number of (Owner of (Buying unit))) Equal to 8
                                • Then - Actions
                                  • For each (Integer A) from 35 to 39, do (Actions)
                                    • Loop - Actions
                                      • Visibility - Destroy herovisiblity[(Integer A)]
                                • Else - Actions
 

Corleone

New Member
Reaction score
44
Instead of having some crazy long trigger with lots of if/then/else functions, you could try something like this:

Trigger:
  • Actions
    • For each (Integer A) from (Player number of (Owner of (Triggering unit))) to ((Player number of (Owner of (Triggering unit))) + 3), do (Actions)
      • Loop - Actions
        • Visibility - Destroy herovisibility[(Integer A)]
 

jig7c

Stop reading me...-statement
Reaction score
123
and also

replace Integer A
with
4 + (Integer A * 4)] in the actions
 

N582114

New Member
Reaction score
2
Like this?

Trigger:
  • For each (Integer A) from (Player number of (Owner of (Buying unit))) to ((Player number of (Owner of (Buying unit))) + 3), do (Actions)
    • Loop - Actions
      • Visibility - Destroy herovisiblity[(4 + ((Integer A) x 4))]
 

N582114

New Member
Reaction score
2
This doesn't work. It appears to be how the variables are set.

The visibility modifiers don't get destroyed/disabled even by setting a specific one to a specific variable, however.
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top