Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Breaking functions run in other threads?

Asked by 8 years ago

Will using break in a scope end any functions running in a separate thread under the same scope? If not, is there a way to do this efficiently? For instance,

i = 5

function Thingy()
    function FunctionInOtherThread()
        if i = 5 then
            for a = 1, 5 do
                print("i = 5")
                wait(10)
            end
        end
    end
    spawn(FunctionInOtherThread)
    repeat
        print("repeating til I break")
    until i == 6
    if i == 6 then break  --If I break here, will it end/stop/break FunctionInOtherThread(), in the other thread?
end

Like I wrote in the comment, would the FunctionInotherThread() break if I break Thingy()? Any help is appreciated, thanks!

P.S. I made that code up on the fly for an example, just saying. :)

1 answer

Log in to vote
1
Answered by 8 years ago

The simple answer is no. It also depends on how your code is. If there are other events in the function after your loop, it will continue and will not end. Break is designed to stop any loop in which it is located in. With this being the loop itself will stop, but the rest of the function will not. Also keep in mind that a function can be re-called so the loop can be broken as many times as the function is called with set conditions

Ad

Answer this question