How to set chunkname for Lua chunk?

I am currently using the C API call luaL_loadstring()to load a piece, but this call has no way to name a piece.

Is there a way to name a piece after loading it?

Alternatively, I see that the function lua_load()accepts the chunkname parameter, but I have not found examples of how to use it: how to replace the call luaL_loadstring()with lua_load()?

+3
source share
1 answer

Use luaL_loadbuffer(L,s,strlen(s),name).

+5
source

All Articles