seperate running of plugins

BECOME PART OF THE COMMUNITY - Sign up here
  • Dear sirs and madams,

    I see in some of the examples of plugins that there is 1 main function running that contains all the other programming / functions within:

    Code
    return function()
    
    local function1()
    end
    
    local function2()
    end
    
    end

    I noticed that the desk does a lot of internal workings and at the end comes with 1 big result. This seems to slow down the process and is memory intensive.

    is it possible to make something that does:

    so lua creates 1 sequence and stores it, and then starts with the second one and stores it, instead of doing them all inside the memory , and storing 5 at the same time.

    Will a cleanup() function help in this process?

    thanks for the help forum hyve mind,

    the struggle is real, but the reward is bigger.

  • I think I understand what your getting at.

    Basically what is happening is your plugin typically runs till completion, While it's doing that the console needs to wait. Because you are running a very ong loop you should hand control back to the console within the loop so it can do some work before returning to you.

    For example (Don't do this! )

    Code
        for i = 1, 10, 1 do
            Cmd("Clear")
            local start = os.clock()
            while os.clock() - start <= 1 do end this will loop for 1 second.
        end
        Echo("Done")

    The result will be the console is unresponsive for 10 seconds then you see 10 Clears on the command line at once.

    Instead do this:

    Code
        for i = 1, 10, 1 do
            Cmd("Clear")
            coroutine.yield(1) -- Give the console back control for 1 Second then return on the next line (restarting the loop).
        end
        Echo("Done")

    Now you will see a clear every second, but during the 10 seconds the console is still usable.

    Here is an example of this where the fader will move for an indeterminate amount of time. Also here where this LUA command can run forever but the console is still usable.


    I think that is what you were looking for.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!