🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Lua - Loading from memory

Started by
1 comment, last by __Daedalus__ 20 years ago
Is there a way to load Lua scripts from memory? For example, at the moment I call lua_dofile() and supply a Lua state and filename. What I want to do is copy my Lua file from my PAK file in to memory and load it from there. Thanks
Advertisement
There are 2 functions that you can use to accomplish this:

LUALIB_API int lua_dobuffer (lua_State *L, const char *buff, size_t size,                          const char *name) {  return aux_do(L, luaL_loadbuffer(L, buff, size, name));}LUALIB_API int lua_dostring (lua_State *L, const char *str) {  return lua_dobuffer(L, str, strlen(str), str);}


These are taken from the source code in the aux library, the same that provides lua_dofile.

EDIT: spelling nazi syndrome ;)
Wonderful! Thank you [smile]

This topic is closed to new replies.

Advertisement