Sign in to follow this  
Malchivus

lua and newline

Recommended Posts

i want ot be able to load all my files into memory before runtime, if possible. by parseing the lua files and replaceing the '\n' with a ';' will i be able to send the whole file at once to lua with lua_dostring? or should i just call it for each line and let the interpreter worry about what to do? or is this all irelevant and all i can pass it the whole file as a STRING because lua won't care if the STRING to lua_dostring is composed of more than one LINE? PS: is there anyway to find out how many arguments are on the stack when lua calls a c callback function?

Share this post


Link to post
Share on other sites
As far as that goes, just call dofile, but yes, you can load the entire file at once into one string and call dostring on it.

You might get the size of the stack before the callback and then once again before you start retrieving values from the stack. I don't know how you're binding your C functions but it shouldn't be too hard to add a couple of lines to the callback manually(hope you don't have too many).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this