Calling a function from a string #1979
Answered
by
fatboychummy
CrimboJimbo
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
fatboychummy
Sep 22, 2024
Replies: 1 comment 12 replies
-
|
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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"