ImI'm making an engine in c++C++ with luaLua for its scripting language (using luabridge forLuaBridge as the binding), so i.
I have a lot of entities, and those entities hashave components, one. One of the components that i haveon those entities is of course a script component, but, everytime i. Every time I want to call a different function from a lua fileLua script, iI always have to call luaL_dofile, and ifluaL_dofile. If I docall this with more than 20 times, i mean, with 20 scripts, my engine gets REALLY slow like,game takes too much time per frame reducing it to 5 fpsFPS on my machine. Every script has a Initan Init, FixedUpdateFixedUpdate, UpdateUpdate, and ShutdownShutdown function, so for. For every script, i call the Init function, for every script iI call the update function, and so on..all of these functions in order.
There'sIs there a solution for thatway to reduce the latency introduced in each frame from using Lua? I really hope someone could help me.
Some pseudo code of my usage of LuaBridge:
//..in voidIn update(floatUpdate dt)..function:
for (int i = 0; i < scripts.size(); i++)
{
luabridge::LuaRef func = luabridge::getGlobal(L, "Update");
if(func.isFunction())
func(dt);
}