Jump to content

Inserting functions in table


Tox

Recommended Posts

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 
     } 
}  

Link to comment
  • Moderators

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]() 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...