If you are using table.insert() and table.remove() to alter the list contents of a table, it doesnt matter what the element / value is, so yes: you can add functions and remove them again.
For example:
function a()
print("a")
end
function b()
print("this is from b")
end
local tbl = {}
table.insert(tbl, "hello") -- string value
table.insert(tbl, 42) -- number - the answer to life, the universe and all that
table.insert(tbl, a ) -- the function a
table.insert(tbl, b ) -- the function b
table.insert(tbl, "last one!") -- string again
You wouldnt be able to just print() this table, but you can freely add any value you want to the table and then use type() to check what's inthere :)/>/>/>
EDIT:
I forgot to add this:
Basically a table couldnt care less what you put in it. As long as you keep track of your table contents, it'll work out fine.
You can use this to iterate through the above table sample and figure out what's what:
for i = 1, #tbl do
if (type(tbl[i]) == "string") then
print("string value: "..tbl[i])
elseif (type(tbl[i] == "number") then
print("number value: "..tbl[i])
elseif (type(tbl[i] == "function") then
local fnc = tbl[i]
fnc() -- This executes the function
end
end
I find it easier to execute functions in a table, by copying them into a local variable first.
In one build, I had a table strictly containing different functions, that I looped through and had each executed. Sort of a function queue if you want. Each function did something different, but all of them had no parameter, so it felt easier doing it that way. I used that setup to queue up functions while my device was in it's "offline" state. As soon as I switched it to it's "online" state, it would start looping through the function queue and execute each of them in the order I had added them. Later on I decided that it would be cheaper to use string commands and a couple of if-then's to execute the same stuff and stopped using the function table.