[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Some questions about embeding
- From: Sergey Mereutsa <serj@...>
- Date: Thu, 2 Dec 2004 12:04:28 +0200
Hi!
I I`m writing a simple GUI for our game and we decided to use Lua as
scripting language (not only for GUI, but for game logic too).
I`v played a bit with Lua integration - it is easy,
but I have some question I want to find answer before I`ll move
forward.
1) Is Lua library thread-safe, i.e. can I share the same Lua state
between threads without explicit locking via semaphores/mutexes ?
Can I have several Lua states for each thread ?
Or I should recompile it with specific options or use explicit locking ?
2) What is ithe best and "native" way for Lua integration - have one
big script, load it once and make needed function calls or split
functions into several files and load them when they needed ?
For example (may be my English is not so clear), I have several GUI
elements, like buttons, memo fields, etc. Assume I have 2 buttons,
each button has method like onMouseOver(). This method must call
separate lua-functions - let say f1() and f2().
Should I put those f1() and f2() functions into one big script
"mygui.lua" and load this file, or I can put them into separate files
and load them when needed ?
3) From my experience, I can do several calls like:
if (luaL_loadfile(L, "function1.lua")|| lua_pcall(L, 0, 0, 0))
{
cout<<"\nCannot run configuration file: "<<lua_tostring(L, -1);
}
if (luaL_loadfile(L, "function2.lua")|| lua_pcall(L, 0, 0, 0))
{
cout<<"\nCannot run configuration file: "<<lua_tostring(L, -1);
}
To load several chunks one-afer-one. Is there any limitations or
any other pitfalls ?
--
Best regards,
thank You in adnvance,
Sergey
mailto:serj@dqteam.com -or-
mailto:serj@mediafon.md