Jump to content

Call function from a string


Recommended Posts

Posted

Hi there again,

I want to know if it's possible to call a function with his name as a string.

Per example i have:

function myFunctionName() 
  
end 

and in another part of my code, I've:

local theFunction = "myFunctionName"; 

It's possible to call the function using theFunction() ?

Thanks.

Posted

All global variables are stored in the table _G with their names as keys. So myFunctionName is _G["myFunctionName"]

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