• 🏆 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!

[Trigger] Regarding Integer

Status
Not open for further replies.
Level 29
Joined
Oct 24, 2012
Messages
6,543
It is only displaying the number 3 because you are overwritting it.
  • For each (Integer TempIntegerArray[1]) from 0 to 2, do (Actions) <--- Loops 3x
    • Loop - Actions
      • Set TempIntegerArray[1] = (TempIntegerArray[1] + 1) <--- Inside the Loop
Should be this.
  • For each (Integer tempInt) from 1 to 3, do (Actions) <--- Loops 3x
    • Loop - Actions
      • Set TempIntegerArray[tempInt] = tempInt <--- Inside the Loop
Display like this.
  • For each (Integer tempInt) from 1 to 3, do (Actions) <--- Loops 3x
    • Loop - Actions
      • game - display message Integer to string ( TempIntegerArray[tempInt] )
The above will display 1 2 3.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
  • For each (Integer tempInt) from 1 to 3, do (Actions) <---- Why was the Array removed?
    • Loop - Actions
      • Set TempIntegerArray[tempInt] = tempInt <---- Why are you storing in the Array and not the Integer?
What mine does is this
  • Set TempIntegerArray[1] = 1
  • Set TempIntegerArray[2] = 2
  • Set TempIntegerArray[3] = 3
If you display each of them in order you get 1, 2, 3. ( order is based on the index. ) ( index is the number inside [] )
You can also do something like this.
  • Set TempIntegerArray[1] = 100
  • Set TempIntegerArray[2] = 12
  • Set TempIntegerArray[3] = 1
If you display each of them in order you get 100, 12, 1.

AIMING FOR
  • For each (Integer TempIntegerArray[1]) from 1 to 3, do (Actions) <---- Is there a reason not to use the Integer instead of the Array that I'm unaware of?
    • Loop - Actions
      • Set TempIntegerArray[1] = TempIntegerArray[1] <---- I need it stored in the Integer not the Array
FINAL
  • For each (Integer TempIntegerArray[1] <---- Need
    • Loop - Actions
      • Set StoreIntegerHere[NotHere] = StoreIntegerHere[NotHere] <---- I need it stored in the Integer not the Array

Your above makes no sense. Variables only hold one thing.
I have no idea what this is supposed to mean.
- I need it stored in the Integer not the Array ......
For the not here in this.
  • StoreIntegerHere[NotHere]
Nothing is ever stored there. That is the integer which tells what index of the array you are looking for.
A non-arrayed variable doesn't have the index as it does not need it.
There is only one thing that variable can be.
An arrayed variable is like a list of variables.
This is a variable StoreIntegerHere[1] same like this is a variable. StoreIntegerHere
The one with the brackets and index is an arrayed variable. The one without it is a non-arrayed variable.
You should look up tutorials on basic standing of arrays if you still don't understand that.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
  • Set ExampleArray[TempIntegerArray[1]] = Example 1
  • Set TempIntegerArray[1] = (TempIntegerArray[1] + 1) <--- This adds to the Array?
+1 <---- This is adding to the Array? I was told otherwise
That is adding to the variable in the array with index of 1 in your example.

  • Set ExampleArray[TempIntegerArray[2]] = Example 1 <--- Array goes from 1 to 2 ?

Example 1 doesn't mean anything to me so I have no idea what you are referring to.
 
Level 12
Joined
Mar 17, 2007
Messages
412
You never really explain what you are trying to do but. I think you are trying to store AbilityRed 1, AbilityGreen 2, AbilityBlue 3 into the array using a loop.
This is not possible. To store anything into an array using a loop you need to use a formula.

Not the ability just a number, the Array represents a number, the Index would be the tier set number
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Ok if you are using. This as the index. IntegerArray[1]

Then you need to do what I said in post #10

Variables can only point to one single thing. Yours is an integer so it can only point to one integer.

Example:
  • // It starts as zero.
  • Set IntegerArray[1] = 0
  • Set IntegerArray[1] = (IntegerArray[1] + 1)
  • Game - Display message Integer to string IntegerArray[1]
  • // The message will display 1 not 0
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
A multidimensional array is not anything that you have explained yet.

Here is a multidimensional array.
  • Events
    • Unit Dies
  • Conditions
  • Actions
    • Set TempTriggerPlayer = triggering player.
    • Set TempInteger1 = (Player number of TempTriggerPlayer) * 2 + 1
    • Set TempInteger2 = (TempInteger1 + 1)
    • Set IntegerArray[ TempInteger1] = IntegerArray[ TempInteger1] + 1
    • Set IntegerArray[ TempInteger2] = IntegerArray[ TempInteger2] + 1
    • Set TempTriggerPlayer gold to IntegerArray[ TempInteger1]
    • Set TempTriggerPlayer lumber to IntegerArray[ TempInteger2]
Here is the breakdown.
For the gold counter.
  • Set TempInteger1 = (Player number of TempTriggerPlayer) * 2 + 1
For the lumber counter.
  • Set TempInteger1 = (Player number of TempTriggerPlayer) * 2 + 2
or more efficiently this.
  • Set TempInteger2 = Set TempInteger1 + 1
The 2 is the width. What that means is it is how many items you want to store for that player. I store Gold and Lumber so it gets set to 2.
The one is the constant for gold. You add one to get the index for the gold.
You add 2 to get the index for the lumber.
So for player one red the golds index would be 1 * 2 + 1 Which is 3.
For player one red's lumber index would be 1 * 2 + 2 Which is 4.
 
Status
Not open for further replies.
Top