- Joined
- Jan 15, 2013
- Messages
- 251
i make one loop, 1 to 5, but when i create an action for display value of Integer A, it shows 6, WHY? 

Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.

For each (Integer A) from 1 to 5, do (Actions)

Loop - Actions


Set MEQS_Integer[0] = (Integer A)


Set MEQS_Integer[1] = (Load (19 + MEQS_Integer[0]) of MEQS_InfoQN from MEQS_Hashtable)


Custom script: set udg_MEQS_UnitType[1] = udg_MEQS_Integer[1]


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




MEQS_UnitType[1] Equal to MEQS_UnitType[0]



Then - Actions




Hashtable - Save ((Load (16 + MEQS_Integer[0]) of MEQS_QuestNumber from MEQS_Hashtable) + 1) as (16 + MEQS_Integer[0]) of MEQS_QuestNumber in MEQS_Hashtable




Trigger - Run sTRING <gen> (checking conditions)




Game - Display to (All players) the text: (String((Integer A)))



Else - Actions
what is it? ITE?
If (All Conditions are True) then do (Then Actions) else do (Else Actions)

If - Conditions


MEQS_UnitType[1] Equal to MEQS_UnitType[0]

Then - Actions


Hashtable - Save ((Load (16 + MEQS_Integer[0]) of MEQS_QuestNumber from MEQS_Hashtable) + 1) as (16 + MEQS_Integer[0]) of MEQS_QuestNumber in MEQS_Hashtable


Trigger - Run sTRING <gen> (checking conditions)

Else - Actions
Game - Display to (All players) the text: (String((Integer A)))

For each (Integer B) from 1 to 5, do (Actions)

Loop - Actions


Set MEQS_Integer[0] = (Integer B)


Set MEQS_Integer[1] = (Load (19 + MEQS_Integer[0]) of MEQS_InfoQN from MEQS_Hashtable)


Custom script: set udg_MEQS_UnitType[1] = udg_MEQS_Integer[1]


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




MEQS_UnitType[1] Equal to MEQS_UnitType[0]



Then - Actions




Hashtable - Save ((Load (16 + MEQS_Integer[0]) of MEQS_QuestNumber from MEQS_Hashtable) + 1) as (16 + MEQS_Integer[0]) of MEQS_QuestNumber in MEQS_Hashtable




Trigger - Run sTRING <gen> (checking conditions)




Game - Display to (All players) the text: (String((Integer B)))



Else - Actions
Untitled Trigger 001

Events


Unit - A unit Dies

Conditions

Actions


Set MEQS_Unit[0] = (Killing unit)


Set MEQS_Player = (Owner of MEQS_Unit[0])


Set MEQS_UnitType[0] = (Unit-type of (Triggering unit))


For each (Integer MEQS_LOOP) from 1 to MEQS_Quest_Index, do (Actions)



Loop - Actions




Set MEQS_QuestNumber = ((Player number of MEQS_Player) x (1000 + MEQS_LOOP))




Set MEQS_InfoQN = MEQS_LOOP




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Load 1 of MEQS_QuestNumber from MEQS_Hashtable) Equal to 1





Then - Actions






For each (Integer B) from 1 to 5, do (Actions)







Loop - Actions








Set MEQS_Integer[0] = (Integer B)








Set MEQS_Integer[1] = (Load (19 + MEQS_Integer[0]) of MEQS_InfoQN from MEQS_Hashtable)








Custom script: set udg_MEQS_UnitType[1] = udg_MEQS_Integer[1]








If (All Conditions are True) then do (Then Actions) else do (Else Actions)









If - Conditions










MEQS_UnitType[1] Equal to MEQS_UnitType[0]









Then - Actions










Hashtable - Save ((Load (16 + MEQS_Integer[0]) of MEQS_QuestNumber from MEQS_Hashtable) + 1) as (16 + MEQS_Integer[0]) of MEQS_QuestNumber in MEQS_Hashtable










Trigger - Run sTRING <gen> (checking conditions)










Game - Display to (All players) the text: (String((Integer B)))









Else - Actions





Else - Actions
Initialize

Events


Map initialization

Conditions

Actions


-------- Index 1 --------


Set UnitType[1] = Footman


Set Message[1] = Footman has died.


-------- /////////////// --------


-------- .................. --------


-------- .................. --------


-------- Index n --------


Set UnitType[5] = Knight


Set Message[5] = Knight has died.


-------- /////////////// --------


-------- Total Index --------


Set TotalIndex = 5
Unit Dies

Events


Unit - A unit Dies

Conditions

Actions


For each (Integer LoopingInteger) from 1 to TotalIndex, do (Actions)



Loop - Actions




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Unit-type of (Triggering unit)) Equal to UnitType[LoopingInteger]





Then - Actions






Set Counter[LoopingInteger] = (Counter[LoopingInteger] + 1)






Set LoopingInteger = TotalIndex





Else - Actions
So, Unit Type 1, Counter 1, Message 1, right ?
Why don't you do it like this;
Initialize
Events
Map initialization
Conditions
Actions
-------- Index 1 --------
Set UnitType[1] = Footman
Set Message[1] = Footman has died.
-------- /////////////// --------
-------- .................. --------
-------- .................. --------
-------- Index n --------
Set UnitType[5] = Knight
Set Message[5] = Knight has died.
-------- /////////////// --------
-------- Total Index --------
Set TotalIndex = 5
As said by others, don't use IntegerA/B, use your custom-variable, namely LoopingInteger - For Each Integer Variable
Unit Dies
Events
Unit - A unit Dies
Conditions
Actions
For each (Integer LoopingInteger) from 1 to TotalIndex, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Triggering unit)) Equal to UnitType[LoopingInteger]
Then - Actions
Set Counter[LoopingInteger] = (Counter[LoopingInteger] + 1)
Set LoopingInteger = TotalIndex
Else - Actions
Explain.as they leak
Explain.
integer bj_forLoopAIndex=0
integer bj_forLoopAIndexEnd=0
integer bj_forLoopBIndex=0
integer bj_forLoopBIndexEnd=0
It cannot leaks because it maps to integer globals. These neither allocate or deallocate anything when used.
JASS:integer bj_forLoopAIndex=0 integer bj_forLoopAIndexEnd=0 integer bj_forLoopBIndex=0 integer bj_forLoopBIndexEnd=0