Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Lua variables lose their value between script calls?

In a C app when I call a Lua script, do the variables in the code stay with the same value when I call the script again later?

like image 226
Fernando Pinheiro Avatar asked Jul 12 '10 17:07

Fernando Pinheiro


1 Answers

They will still exist in the lua state you created until you close that state. The variables are tied to the state not the script file.

edit

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

like image 159
Nick Van Brunt Avatar answered Oct 14 '22 08:10

Nick Van Brunt