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

How do you make a function that activates and deactivates another function?

Asked by
Yeevivor4 155
10 years ago

Hello. I am wondering, how do you make a function that activates and deactivates a function? The 1st Function's name is turnOn and the 2nd Function is named turnOff.
-- If you can add how to stop the function when another function is still in action, it would help me a lot.

1 answer

Log in to vote
0
Answered by
jav2612 180
10 years ago
function1enabled = true
function2enabled = true

function function1()
    if function1enabled == true then -- checks to see if this function has been turned off
        function2enabled = false -- this turns off the second function
        -- do stuff here
    end
end

function function2()
    if function2enabled == true then -- checks to see if this function has been turned off
        function1enabled = false -- turns off the first function
        -- do stuff here asdfadsadsf
    end
end

Something like that?

Ad

Answer this question