开发者

Do Lua variables lose their value between script calls?

开发者 https://www.devze.com 2023-01-07 08:16 出处:网络
In a C app when I call a Lua script, do the varia开发者_JS百科bles in the code stay with the same value when I call the script again later?They will still exist in the lua state you created until you

In a C app when I call a Lua script, do the varia开发者_JS百科bles in the code stay with the same value when I call the script again later?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号