Breaking a loop

nomadian

Member
Reaction score
9
Code:
For each (Integer A) from Random to 10, do (If (((Player((Integer A))) slot status) Equal to Is playing) then do (Skip remaining actions) else do (Set Random = (Random + 1)))

That's my code, I'm wondering if that 'Skip remaining actions' breaks the loop or not?
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
You could easily test it with displaying text or something but I think it does.
 

jomik

New Member
Reaction score
17
I don't understand the way you want the code, can you explain ? - But yeah it should :O

EDIT: Damn Sgqvur beat me to it :D
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
That's my code, I'm wondering if that 'Skip remaining actions' breaks the loop or not?

It will exit the loop, and stop the whole trigger at that point.

If you just want to exit the loop, use [ljass]Custom script: exitwhen true[/ljass]
 

Rushhour

New Member
Reaction score
46
Well, having an [ljass]exitwhen true[/ljass] in a loop makes the loop run only once or never, so
Trigger:
  • CustomScript(exitwhen <yourcondition>==true)
will be, what you are looking for.^^

And "Skip remaining actions" is a single [ljass]return[/ljass] which stops all of the following code no matter which code and where it appears
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Well, having an [ljass]exitwhen true[/ljass] in a loop makes the loop run only once or never
Not if it is within an If statement, as was the case in the original post (and is a more GUI-style way of doing it than making the conditional statement in the custom script).

I'm not really sure what is the goal of nomadian's code, though.
 

Rushhour

New Member
Reaction score
46
Loops in GUI are a pain anyhow.. ;D
Really, learn the basics of Jass; it will be so much easier and faster to do such things.

If you're interested look at the following function, if not ignore it, but it does what your piece of code does and is so much easier to edit.

JASS:
function Name takes nothing returns nothing
local integer random=0 //assuming random is 0 at start
loop
  exitwhen random>=11
  if GetPlayerSlotState(Player(random)) == PLAYER_SLOT_STATE_PLAYING then
       return
  else
       set random=random+1
  endif
endloop
endfunction
 

perkeyone

something clever
Reaction score
71
if you dont want to learn jass just to solve one tiny problem,
you could put the loop in a trigger by itself and turn the trigger off,
and a skip remaining actions event to the loop
then run the loop trigger from the original trigger
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top