Ok so, this is more a sanity check than anything else.
Lets asume we have a struct called lua_State, now I need to create a uncertain amount of unique lua_State's. To make sure I don't use the same variable name twice I would need to have some sort of way to get an unique variable every time i make a new state.
However there is only one way (I think?) to create a new state, and that is as follows:
lua_State *S = lewL_newstate();
Now I would need some way to dynamically change that "S" to.. whatever.
For example: If I had 4 lua files, and I wanted to load each into their own lua_State, I would call: lua_State *A = lewL_newstate(); for the first, lua_State *B = lewL_newstate(); for the second, and so on. Keep in mind the number of lua files varies so creating a fixed number of states probably won't go over well.
How would I go about doing this?
clarification:
.h
struct lua_State
.cpp
createNewState(Lua_State* something){
lua_State* something = luaL_newstate();
}
I thought about creating a
std::map<int, lua_State*> luaMap;
but then I would still have the problem of actually generating (for lack of better words) a variable name for every int-index.
So, have I been drinking too much coffee and is there a glaringly obvious simply solution to what I am trying to do, or should I just stop coding untill the crazy blows over?
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…