• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

help with a loop

Status
Not open for further replies.
Level 17
Joined
Jul 17, 2011
Messages
1,863
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