Skip to content

Calling a function from a string #1979

Answered by fatboychummy
CrimboJimbo asked this question in Q&A
Discussion options

You must be logged in to vote

To clarify, when you declare a variable (or function) without the local keyword, Lua always puts the value into _ENV. This is the case in CC as well, but CC creates an _ENV that is specific to each program, then an actual global _G (whereas in base lua, both tables are the same).

If you want something put in _G instead of _ENV, you need to prefix your declaration with _G., i.e: _G.variable = "global variable"

Replies: 1 comment 12 replies

Comment options

You must be logged in to vote
12 replies
@zyxkad
Comment options

@CrimboJimbo
Comment options

@fatboychummy
Comment options

@fatboychummy
Comment options

Answer selected by CrimboJimbo
@CrimboJimbo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants