• 🏆 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!

[JASS] My first jass function (doesnt leak)

Status
Not open for further replies.
Level 6
Joined
Oct 31, 2008
Messages
229
Heres my first jass function and doesn't leak. Deep within me i always loved jass but preferes GUI instead for some reason

JASS:
function Forloopnew takes real A, real B, real Step returns nothing
//This function, is a normal "for-loop" function, not the stuff blizzard provides with WE. 

//Takes real A, real B and step and you may ad a function in it 

//(be sure to add the script twice. And yes. I know there is a better way 

//but is not bd for first time dnt you think?

//It can work with reals, have negative ending values

//skips infinite loops and all that.
    local real i = A
    if Step > 0 then
    loop
        exitwhen i > B
        call DisplayTextToPlayer (Player(0),0,0,R2S(i))//Or whatever you wan't
        set i = i + Step
    endloop
    endif
    if Step < 0 then
    loop
        exitwhen i < B
        call DisplayTextToPlayer (Player(0),0,0,R2S(i))//Excactly as above
        set i = i + Step
    endloop
    endif
    if Step == 0 then
    call DisplayTextToPlayer (Player(0),0,0,"Internal looprun step == 0")
    endif
    
    //Mine first jass script (lol)
    endfunction
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Except you can put any condition on earth in the middle, and as much actions you want in both sides.
For example:
JASS:
set i = 0
set j = 0
set k = vec3(0,1,2)
... // whatever initializations you have

loop
    exitwhen conditions

    [code]

    set i = i + 1
    set j = j + 82
    set k = k + vec3(2,1,0)
    ... // whatever you want every iteration
endloop


I still don't see how this code relates to any kind of loop. I really don't get the purpose of it.
 
Status
Not open for further replies.
Top