In my application a Lua script can subscribe to certain events from a Client. It is also possible to have one script subscribe to multiple Clients. Currently I am setting the global "Client" every time I want to call the script so that the script can access the Client that made the callback. What I would want is something like a thread local in C++ so that I could create a new Lua thread for every client and just set the "Client" variable for that thread once. If the client then fires the event it would just use the thread that it is associated with.
TLDR: Is it possible to have variables in Lua that are only valid within a specific Lua thread?
See Question&Answers more detail:os