lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Just define some functions in Lua code, dobuffer only once, and call the Lua
functions from C++ code... The Lua functions don't vanish anywhere after
dobuffer returns.


Regards,
Jani

----- Original Message -----
From: "Jens Hassler" <lukey@gmx.de>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Sunday, September 29, 2002 12:42 PM
Subject: efficient calling of lua code


> Hi there,
>
> I just read the last posts and found one mentioning lua_dostring() is
> not efficient for calling lua code in each game cycle.
>
> My game currently does the following:
>
> 1. load the clear text script into an array (script_buffer)
> 2. execute the script in each game cycle by calling:
>
>    lua_dobuffer(L, script_buffer, sizeof(script_buffer), "levelscript");
>
>
> This works very good, but rather slow. What would be a better way to do
> this? Can I load the script into memory (as I did) and compile it there
> (how?)?
>
>
> Thanks!
> Jens