Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the chunkname of a Lua chunk?

Tags:

chunks

lua

I'm currently using the C API call luaL_loadstring() to load a chunk, but this call doesn't have a way of naming the chunk.

Is there a way of naming a chunk after it's loaded?

Alternatively, I see the lua_load() function takes a chunkname parameter, but I haven't found any examples of how to use it: How can I replace a luaL_loadstring() call with lua_load()?

like image 207
Roddy Avatar asked Dec 21 '25 23:12

Roddy


1 Answers

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

like image 54
lhf Avatar answered Dec 25 '25 21:12

lhf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!