You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't understand how loading byte code and compiling Lua script works, and I couldn't find anything online. I basically need some way to run Lua code from a string file, but I managed to get this far and I have no idea what the chunkname is supposed to be and how to make/create it. Any help would be appreciated.
#include<luau/VM/include/lua.h>
#include<luau/VM/include/lualib.h>
#include<luau/Compiler/include/luacode.h>classLuauLoader {
private:
lua_State* L;
public:LuauLoader() {
L = luaL_newstate(); // Initialize new Lua stateluaL_openlibs(L); // Open standard libraries
}
~LuauLoader() {
lua_close(L); // Close Lua state
}
voidexecuteScript(const std::string& script) {
size_t bytecodeSize = 0;
char* bytecode = luau_compile(script.c_str(), script.size(), NULL, &bytecodeSize);
int result = luau_load(L, "[chunkname]", bytecode, bytecodeSize, 0);
free(bytecode);
}
};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I don't understand how loading byte code and compiling Lua script works, and I couldn't find anything online. I basically need some way to run Lua code from a string file, but I managed to get this far and I have no idea what the chunkname is supposed to be and how to make/create it. Any help would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions