Reputation: 87
I have a function that will create a function and insert that function in the table it somewhat goes like this.
local Events = {}
Events.Functions = {}
Events.AddEvent = function(code1)
local Event = function(code1)
loadstring(code1)
end
table.insert(Events.Functions, Event)
end
Events.AddEvent("print(\"hello\")")
Upvotes: 2
Views: 594
Reputation: 122373
loadstring
(or load
in Lua 5.2 or higher) itself returns a function, you don't need the extra function
when defining Event
:
local Event = loadstring(code1)
table.insert(Events.Functions, Event)
Or simply:
table.insert(Events.Functions, loadstring(code1))
Upvotes: 2