[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Attach Lua script To C++ class!
- From: "Ive" <neosettlers@...>
- Date: Mon, 18 Jul 2005 15:40:20 -0400
O interesting!
Can u be more precise on this and/or point me to some example?
thx
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Jason Murdick
Sent: Monday, July 18, 2005 3:35 PM
To: Lua list
Subject: Re: Attach Lua script To C++ class!
Sure it is! The two ways I've stored scripts inside C++ classes is to
simply store the script as a string or as a filename/path.
Jason
On 7/18/05, Ive <neosettlers@sympatico.ca> wrote:
> Am I at the right place to discuss this?
>
> ...
>
> Alright!
>
> What I m trying to do is to assign to each actor in a game environment
a
> script ai!
>
> I m wondering if I must do:
>
> lua_State *m_lua;
>
> if ((m_lua = lua_open()) == NULL)
> {
> Trace("ERROR: LUA initialization failed!\n\n");
> }
> else
> {
> Trace("TELL: LUA initialization successful!\n\n");
>
> luaopen_base(m_lua);
> luaopen_table(m_lua);
> luaopen_io(m_lua);
> luaopen_string(m_lua);
> luaopen_math(m_lua);
> luaopen_debug(m_lua);
>
> RegisterFunction(); /// register all functions
>
> Int l_status = luaL_loadfile(m_lua, in_name.GetName());
> lua_settop(m_lua, 0);
>
> if (l_status != 0)
> {
> lua_error(m_lua);
> }
> }
>
> to each of the script!
>
>
> Then update them individually each frame with:
>
> lua_pcall(m_lua, 0, 0, 0);
>
> or
>
> my first guest is to have only one lua_State instance and register all
> functions once and then keep track with a pointer to each
> luaL_loadfile... but I cant find the way to retrieve them... can
anyone
> clear this up please?
>
> Is lua_open() should be call once (then register all possible
functions
> once) or to all attached scripts? What is the ultimate way to do this
> with out unnecessary overheads?
>
> thx
>
>
>