lua-users home
lua-l archive

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


> As you can see, I am creating a temporary global variable _tmp to hold the
> value of the expression.  I understand that the code for dostring will do
> some temp allocations as well.  The eventual collection of these things
> takes so much time that the frame rate suffers (there is a noticable pause
> every 1 to 4 seconds).

dostring will not "do some temp allocations as well". dostring is a HEAVY
function. You should always try to avoid calling dostring inside a loop.


> I know that I could avoid the use of _tmp when getting the value of an
> actual global variable (like in the case LuaGetBool(L,
> "gSomeGlobalBoolean")) by using lua_getglobal(),  but there must a better
> way to generically get the value of an expression (as well as members of
> tables) ?

If you have a fixed set of expressions that you want to get the value,
you could (pre) create a Lua function to return each expression and then
only call the respective function when you need the value.

-- Roberto