Staredit Network > Forums > SC2 Assistance > Topic: Array index arithmetic problems
Array index arithmetic problems
May 3 2010, 12:51 am
By: LostInMyself  

May 3 2010, 12:51 am LostInMyself Post #1



I am trying to do arithmetic in an array index and it does not work. I'm assuming an index is an integer.
The array variable is a unit type if it matters and I'm trying to add 1 to an integer in the index of said array.
Any suggestions?



None.

May 3 2010, 5:46 am ZeroAme Post #2



Can you show the trigger and variables your doing it with so we have a better idea of what you mean?



None.

May 3 2010, 2:14 pm LostInMyself Post #3



I have two global variables one is called unitArray[20] and is a unit type array.
The second one is unitArrayIndex and is an integer type.

The trigger is

Event - Any unit construction is completed

Local Variables - None
Conditions - None

Actions - Set unitArray[(unitArrayIndex + 1)] = (Triggering progress unit)



None.

May 3 2010, 8:00 pm Swampfox Post #4



Perhaps modifying a variable OUTSIDE of the array index (Lets call it ArrayIndex :)), and then using that variable instead? Just a thought.



None.

May 3 2010, 8:11 pm ZeroAme Post #5



What is the arry by default? if it 20 by default then it wont add anything because its already at its max.

I'll play around with this in GE and see what I come up with.

Edit: is unitArrayIndex an array?

Post has been edited 2 time(s), last time on May 3 2010, 8:22 pm by ZeroAme.



None.

May 4 2010, 4:28 am LostInMyself Post #6



Quote from Swampfox
Perhaps modifying a variable OUTSIDE of the array index (Lets call it ArrayIndex :)), and then using that variable instead? Just a thought.

After playing around for awhile I eventually came up with this and it does work.
It's just odd that you can't do arithmetic in an array index.

Quote from ZeroAme
What is the arry by default? if it 20 by default then it wont add anything because its already at its max.

I'll play around with this in GE and see what I come up with.

Edit: is unitArrayIndex an array?

unitArrayIndex is not an array and it's default is 0
The array is defaulted to a 20 slot array with 0 (assuming) in each slot.
Even though I solved my problem I would like to figure out why this does not work.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[09:18 pm]
Ultraviolet -- 🔪🐈
[12:34 pm]
NudeRaider -- curiosity kills the cat!
[06:18 am]
Sylph-Of-Space -- No complaints here, i'm just curious!
[2024-5-18. : 11:05 pm]
Ultraviolet -- :wob:
[2024-5-18. : 3:55 pm]
Zoan -- :wob:
[2024-5-18. : 10:34 am]
NudeRaider -- SEN doesn't rely on spammers initiate its sleep cycle. It hat fully automated rest and clean-up phases. Please understand that this is necessary for the smooth operation of the site. Thank you.
[2024-5-18. : 3:45 am]
Sylph-Of-Space -- Does the shoutbox get disabled when there's spammers?
[2024-5-17. : 6:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[2024-5-17. : 5:41 am]
Ultraviolet -- 🤔 so inf is in you?
[2024-5-17. : 4:57 am]
O)FaRTy1billion[MM] -- my name is mud
Please log in to shout.


Members Online: Roy