• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[General] Looping until a point != itself

Status
Not open for further replies.
Hey do you have any idea how to solve this problem?
the idea is:
loop until RaceCurrentInt != RaceRandomInt.
If != , then set it to RaceRandomInt.
The goal here is to avoid setting/re-setting the new point where the previous point was.
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • Set Race_RandomInt = (Random integer number between 1 and Settings_Race_Jumps)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Race_CurrentInt Not equal to Race_RandomInt
        • Then - Actions
          • Set Race_CurrentInt = Race_RandomInt
          • Set Race_CurrentPoint = KOTH_POINTS[(Random integer number between 1 and Settings_Race_Jumps)]
          • Item - Create Race Flag at Race_CurrentPoint
          • Skip remaining actions
        • Else - Actions
 
Last edited:

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,894
Use your own integer loop variable and then inside in the condition instead of the "skip remaining actions" set your new integer loop variable to a value higher so that it forces the exit of the loop. Any number higher than 10 in this case.
 
I think I might solved it
JASS:
function Trig_SetNextPoint takes nothing returns nothing
  
    loop
        exitwhen udg_Race_CurrentInt != udg_Race_RandomInt
        set udg_Race_RandomInt = GetRandomInt(1, udg_Settings_Race_Jumps)
    endloop
    set udg_Race_CurrentInt = udg_Race_RandomInt
    set udg_Race_CurrentPoint = udg_KOTH_POINTS[GetRandomInt(1, udg_Settings_Race_Jumps)]
    call CreateItemLoc( 'rflx', udg_Race_CurrentPoint )
    call DisplayTextToForce( GetPlayersAll(), "A new flag has been spawned! Check the minimap!" )
endfunction

//===========================================================================
function InitTrig_Race_Set_Next_Point takes nothing returns nothing
    set gg_trg_Race_Set_Next_Point = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Race_Set_Next_Point, function Trig_SetNextPoint )
endfunction
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Sure, if you have jass knowledge it is easier. Wrda tried to keep things in GUI.
 
Status
Not open for further replies.
Top