[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Lua threads share global data?
- From: John Klimek <jklimek@...>
- Date: Wed, 21 Dec 2005 19:34:35 -0500
In case nobody saw my last e-mail (from the "Is lua thread safe?"), I
have some more questions... (on top of the questions asked in my last
1) If I create a lua thread, is the global data shared with the main
lua state? The manual seems to contrict itself and says that the data
IS shared but then it says it's not. From doing some tests, it seems
like the data IS in fact shared.
For example, if I load a script (using lua_dofile) and run it on my
thread, the script's global functions show up in my main lua states
My main goal is this...
In my game I will have tons of scripts being run but I need Lua to
know the current user (or NPC or object) running the script. I can
create a global "CurrentUser" userdata but since it's global it is
shared and gets overwritten. I tried creating a thread but that
doesn't seem to help me at all...
2) Once a script is run via lua_dofile(), all functions that were
declared stay in the global table, right? So I can access them later?
3) How can I load a script and NOT execute it but only run a function
contained inside of that script?
Also, if anybody could answer any of the questions from my last e-mail
(about lua beiing thread safe) I would greatly appriciate it.