Tox Posted November 20, 2015 Posted November 20, 2015 hi, is there any way to insert function in a table? I tried to name my function but it came up with an error; my example is below table = { [1] = {"table item", "table item", "event", function testFunction() outputChatBox ("test") end } }
Noki Posted November 20, 2015 Posted November 20, 2015 foo = {} function foo.bar() outputDebugString("Executed foo.bar") end The table would look like foo = {[1] = bar}. Though, bar would be a function (eg: function: 0429DF58) and not a function name.
Moderators IIYAMA Posted November 20, 2015 Moderators Posted November 20, 2015 The only thing you had to do was removing the variable that holds the function. Because you want to insert the function inside the variable 'table' in it's table, and not in the variable 'testFunction'. - testFunction table = { [1] = {"table item", "table item", "event", function () outputChatBox ("test") end } } Execute the function: table[1][4]()
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now