[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to avoid global variables in a lua module (using C api)
- From: Patrick Rapin <toupie300@...>
- Date: Fri, 30 Sep 2011 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,