- Joined
- Mar 27, 2008
- Messages
- 8,035
I have a test map which when a Player select a unit, it gives them an index value.
This trigger will first check whether the unit has been indexed or not (Unit Group).
If yes, it will loop through the index size and check which index does the unit holds.
If no, it will give the unit an index value and add it to Unit Group.
What I meant by the value is messed up is that the value for 2nd unit and so on will start from 11111, I mean why the index does not raised to 2 ?
This trigger works, if and only if, you followed the first step, register all units first without checking their index value, only then it gives the correct value.
If you register 1st unit or any unit and check their index value without registering all index value for next unit(s), the next unit(s)'s index value will get messed up.
How to solve this, but the most important question, why does it turn to 11111 instead of 2 (for the next index value).
This trigger will first check whether the unit has been indexed or not (Unit Group).
If yes, it will loop through the index size and check which index does the unit holds.
If no, it will give the unit an index value and add it to Unit Group.
So, in order to register units and see its index, you gotta follow these step;
1. Select a unit
2. Re-select the selected unit (clicking/drag-select/etc) and then you will see its index value
1. Select a unit
2. Re-select the selected unit (clicking/drag-select/etc) and then you will see its index value
There are 5 units in the test map, everything works great, but you gotta do this step in order for it to successfully gives correct index value to a unit;
1. Select 1st unit
2. Select 2nd unit
3. Select 3rd unit
4. Select 4th unit
5. Select 5th unit
After you have done that, only then you can check their index value correctly
1. Select 1st unit
2. Select 2nd unit
3. Select 3rd unit
4. Select 4th unit
5. Select 5th unit
After you have done that, only then you can check their index value correctly
However, if you do like this;
1. Select 1st unit
2. Re-select 1st unit (or easier way, double-click any 1st unit)
3. Select 2nd unit and so on
4. Index value for 2nd unit and so on will get f**cked up
1. Select 1st unit
2. Re-select 1st unit (or easier way, double-click any 1st unit)
3. Select 2nd unit and so on
4. Index value for 2nd unit and so on will get f**cked up
What I meant by the value is messed up is that the value for 2nd unit and so on will start from 11111, I mean why the index does not raised to 2 ?
This trigger works, if and only if, you followed the first step, register all units first without checking their index value, only then it gives the correct value.
If you register 1st unit or any unit and check their index value without registering all index value for next unit(s), the next unit(s)'s index value will get messed up.
How to solve this, but the most important question, why does it turn to 11111 instead of 2 (for the next index value).
-
Melee Initialization
-
Events
- Player - Player 1 (Red) Selects a unit
- Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Triggering unit) is in IndexGroup) Equal to True
-
Then - Actions
-
For each (Integer Index) from 1 to Index, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to Unit[Index]
-
Then - Actions
- Game - Display to (All players) the text: (This unit has index value of + (String(Index)))
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
For each (Integer Index) from 1 to Index, do (Actions)
-
Else - Actions
- Set Index = (Index + 1)
- Game - Display to (All players) the text: (String(Index))
- Set Unit[Index] = (Triggering unit)
- Unit Group - Add Unit[Index] to IndexGroup
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events