• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

help with a loop

Status
Not open for further replies.
Level 17
Joined
Jul 17, 2011
Messages
1,864
JASS:
 function syncitem  takes nothing returns nothing 
    
             local integer g = 10
             local string s = "0"

             
             local integer id 
 local destructable d 
 local item gg
 
call BJDebugMsg("rodsjflasdjfaldkjf")
    

    loop 
    exitwhen g > 45 
    set g = g + 1 




set s = "00" + I2S(g)




set id = S2A(s)

set d =  CreateDestructableLoc(id, GetRectCenter(GetWorldBounds()), 300, 2, 1 )
set gg = CreateItem(id,0 , 900) 




// the problem is with this condition, if it returns true the loop ends
// after that, if i remove it, the loop goes to 45 and stops
// why does it do that? if the condition returns false the loop still goes 
//through 45 or until it returns true 


 if GetDestructableOccluderHeight(d) == 1.00 then 
 set d_weaponCount  = d_weaponCount  + 1 
 // set  udg_something[ ] = d 
//  set udg_comething[ ] = i 
endif 

endloop

    endfunction
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
Improved spacing:
JASS:
function syncitem  takes nothing returns nothing 
    local integer g = 10
    local string s = "0"
    local integer id 
    local destructable d 
    local item gg
     
    call BJDebugMsg("rodsjflasdjfaldkjf")

    loop 
        exitwhen g > 45 
        set g = g + 1 
        set s = "00" + I2S(g)
        set id = S2A(s)
        set d =  CreateDestructableLoc(id, GetRectCenter(GetWorldBounds()), 300, 2, 1 )
        set gg = CreateItem(id,0 , 900) 

        // the problem is with this condition, if it returns true the loop ends
        // after that, if i remove it, the loop goes to 45 and stops
        // why does it do that? if the condition returns false the loop still goes 
        //through 45 or until it returns true 
        if GetDestructableOccluderHeight(d) == 1.00 then 
            set d_weaponCount  = d_weaponCount  + 1 
            // set udg_something[ ] = d 
            // set udg_something[ ] = i 
        endif 
    endloop
endfunction

Hmh, that shouldn't happen. I see no reason why the loop would end if that condition is true.
The loop in your function should go from 11 to 46 and then stop, whether the condition is true or not doesn't matter.

After testing it myself, it behaved exactly as predicted.
 
Status
Not open for further replies.
Top