Re: How to avoid global variables in a lua module (using C api)
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: How to avoid global variables in a lua module (using C api)
- From: Patrick Rapin <toupie300@...>
- Date: 2011年9月30日 21:30:57 +0200
I would suggest to store your values into the Lua registry.
This fits your needs if there are only one instance of your variables per lua_State, and if you do not need to access them directly from Lua.
The table is accessed easily by the LUA_REGISTRYINDEX pseudo index.
You can either use a sufficiently specific string for the key, or a static pointer pushed as a lightuserdata,
Patrick Rapin