seperate running of plugins

  • 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:

    1. return function()
    2. local function1()
    3. end
    4. local function2()
    5. end
    6. 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! )

    1. for i = 1, 10, 1 do
    2. Cmd("Clear")
    3. local start = os.clock()
    4. while os.clock() - start <= 1 do end this will loop for 1 second.
    5. end
    6. 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:

    1. for i = 1, 10, 1 do
    2. Cmd("Clear")
    3. coroutine.yield(1) -- Give the console back control for 1 Second then return on the next line (restarting the loop).
    4. end
    5. 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.