# Question about a looping trigger

#### EmoBrother

Level 10
Here's my trigger
• Corpse Continues Decay
• Events
• Unit - A unit Dies
• Conditions
• (Unit-type of (Triggering unit)) Equal to Peasant
• Actions
• For each (Integer LoopInteger) from 1 to Int_UnitAfterDead, do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Triggering unit) Equal to Suspended_Corpse[LoopInteger]
• Then - Actions
• Set TempInteger = (Integer A)
• Trigger - Run Remove DummyItems <gen> (checking conditions)
• Set LoopInteger = (Int_UnitAfterDead - 1)
• Else - Actions
JASS:
``````function Trig_ABCD_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'hpea' ) ) then
return false
endif
return true
endfunction

function Trig_ABCD_Func002Func001C takes nothing returns boolean
if ( not ( GetTriggerUnit() == udg_Suspended_Corpse[udg_LoopInteger] ) ) then
return false
endif
return true
endfunction

function Trig_ABCD_Actions takes nothing returns nothing
set udg_LoopInteger = 1
loop
if ( Trig_ABCD_Func002Func001C() ) then
set udg_TempInteger = GetForLoopIndexA()
call ConditionalTriggerExecute( gg_trg_Remove_DummyItems )
set udg_LoopInteger = ( udg_Int_UnitAfterDead - 1 )
else
endif
set udg_LoopInteger = udg_LoopInteger + 1
endloop
endfunction

//===========================================================================
function InitTrig_ABCD takes nothing returns nothing
set gg_trg_ABCD = CreateTrigger(  )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ABCD, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_ABCD, Condition( function Trig_ABCD_Conditions ) )
call TriggerAddAction( gg_trg_ABCD, function Trig_ABCD_Actions )
endfunction``````
Simple questions :
1.The loop will end when I set LoopInteger = (Int_UnitAfterDead - 1) right ?
2.Will the GUI work as Jass ?

Extra question :
What is the difference of vJass and Jass ?

#### Maker

Level 37
You should not use Integer A since you are not using that in the loop. Neihter the gui or jass will work correctly.

The difference between jass and vjass is that vjass introduces some new coding methods. You can check them here: http://www.wc3c.net/vexorian/jasshelpermanual.html

vjass gets compiled into jass when the map is saved.

#### EmoBrother

Level 10
You should not use Integer A since you are not using that in the loop. Neihter the gui or jass will work correctly.

The difference between jass and vjass is that vjass introduces some new coding methods. You can check them here: http://www.wc3c.net/vexorian/jasshelpermanual.html

vjass gets compiled into jass when the map is saved.
Thanks, Maker.
Integer A is my mistake

#### defskull

Level 33
1.The loop will end when I set LoopInteger = (Int_UnitAfterDead - 1) right ?
The condition for the loop to stop is: LoopInteger > Int_UnitAfterDead

If you do this, there will be one leaking loop.
You should just set it equal to.

Set this value just before the udg_LoopInteger = udg_LoopInteger + 1

2.Will the GUI work as Jass ?
Use Custom script.

#### EmoBrother

Level 10
The condition for the loop to stop is: LoopInteger > Int_UnitAfterDead

If you do this, there will be one leaking loop.
You should just set it equal to.

Set this value just before the udg_LoopInteger = udg_LoopInteger + 1
? But I saw the action, set udg_LoopInteger = udg_LoopInteger + 1 so it should be no problem.
JASS:
``````    loop
if ( Trig_Corpse_Continues_Decay_Copy_Func002Func001C() ) then
set udg_TempInteger = udg_LoopInteger
call ConditionalTriggerExecute( gg_trg_Remove_DummyItems )
set udg_LoopInteger = ( udg_Int_UnitAfterDead - 1 )
else
endif
set udg_LoopInteger = udg_LoopInteger + 1
endloop``````

Will this work ?
• Corpse Continues Decay
• Events
• Unit - A unit Dies
• Conditions
• (Unit-type of (Triggering unit)) Equal to Peasant
• Actions
• For each (Integer LoopInteger) from 1 to Int_UnitAfterDead, do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Triggering unit) Equal to Suspended_Corpse[LoopInteger]
• Then - Actions
• Set TempInteger = LoopInteger
• Trigger - Run Remove DummyItems <gen> (checking conditions)
• Set LoopInteger = (Int_UnitAfterDead - 1)
• Else - Actions

#### defskull

Level 33
Let's take a look;

Which means if Int_UnitAfterDead is 5, then LoopInteger is 4.
After that, LoopInteger = LoopInteger + 1
So LoopInteger = 5 now.

The next check is this; 5 > 5 - FALSE
Therefore, the loop will continue once more.

IF we set without the subtraction, here's it would become;

Which means if Int_UnitAfterDead is 5, then LoopInteger is 5.
After that, LoopInteger = LoopInteger + 1
So LoopInteger = 6 now.

Next check would be: 6 > 5 - TRUE
Therefore, exit loop.

#### EmoBrother

Level 10
Let's take a look;

Which means if Int_UnitAfterDead is 5, then LoopInteger is 4.
After that, LoopInteger = LoopInteger + 1
So LoopInteger = 5 now.

The next check is this; 5 > 5 - FALSE
Therefore, the loop will continue once more.

IF we set without the subtraction, here's it would become;

Which means if Int_UnitAfterDead is 5, then LoopInteger is 5.
After that, LoopInteger = LoopInteger + 1
So LoopInteger = 6 now.

Next check would be: 6 > 5 - TRUE
Therefore, exit loop.
Thanks ! Your explanation is very clearly

Replies
3
Views
1K
Replies
6
Views
859
Replies
12
Views
520
[JASS] Local timers
Replies
7
Views
692
[JASS] Trackable bug
Replies
4
Views
802