Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is it possible to "halt" any code execution from within a table?

Something that intrigues me about Lua is the fact that you can run any function from within a table, regardless of whether it returns anything or not.

an example of what I am talking about is:

    local my_table = {
        print("output from a table!");
        warn("more output from a table!");
    };

The funny thing is that as soon as this table is created both functions inside of it are ran, and both my_table[1] and [2] are equal to nil (because print and warn do not return a value). However is there any way to per-say "halt" both functions from executing whenever the table is created, and possibly even "start" running them later, if a certain condition is met or not? I was considering coroutines, however in my case they would not work out too well due to the fact that I am working on an alternate syntax in ROBLOX Lua, and it would not exactly be user friendly and easy to understand. I would appreciate any help; Thanks

1 answer

Oops, I forgot to consider the fact that I am really just storing the result of the function calls in that table. I could simply make a function that takes in the function to be called and the parameters, and then return a function to be called later on.

This discussion is preserved as it was. New answers, comments, and votes are closed.