Lua variables lose their value between script calls?

In C application, when I call the Lua script, are the variables stored in the code with the same value when I call the script again?

+7
variables scripting lua
source share
1 answer

They will still exist in the lua state that you created until you close this state. Variables are bound to state, not to script file.

change

As noted in the comments, local variables will be garbage collected when they go beyond. Another caveat is that Lua supports closures and upvalues, so scope may not always be completely obvious.

+6
source share

All Articles