Jump to content
  • Advertisement
Sign in to follow this  
__Daedalus__

Lua - Loading from memory

This topic is 5126 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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 ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!