🎉 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!
Execute LUA-script one instruction at the time.
Is it possible to gain external control over a script when you embed lua.
I would like to do something like this:
lua_State *l;
l = lua_open();
luaL_loadfile(l,"test.lua");
//... Register my functions.
while(statements_left(l))
{
lua_step(l);
}
I would also like to know if there is a way to set a memory limit for lua_State without having to alter the LUA source.
For single stepping, you can set a line-count-hook. This is primarily useful for debugging your program by single-stepping. If you want to execute part of a script, then stop and come back later and finish it, coroutines are a better bet. Read the manual for details on either.
In terms of setting a memory limit: If you want a hard limit like that, you do need to edit the source. Everything is gathered into lgc.c and lgc.h. It's pretty easy to follow.
In terms of setting a memory limit: If you want a hard limit like that, you do need to edit the source. Everything is gathered into lgc.c and lgc.h. It's pretty easy to follow.
Quote: Original post by Sneftel
Everything is gathered into lgc.c and lgc.h. It's pretty easy to follow.
Offtopic: is there some roadmap to the lua sources, or should I just go ahead and read them?
IIRC, there's a bit of a roadmap to the VM (which is one of the most complex parts) but that's about it, as far as I know. Jump on in.
I tried the lua_sethook function but I can't find a way of hooking statements. And if I were to use coroutines I would have to implement them myself in C since I don't want to enable them for the scripts I'm running.
I like Lua, but I'm not sure that it is the best thing to us for what I'm trying to do.
Do you know if there is a scripting language that can be easily embedded and execute individual statements?
I like Lua, but I'm not sure that it is the best thing to us for what I'm trying to do.
Do you know if there is a scripting language that can be easily embedded and execute individual statements?
Quote: Original post by qwert
I tried the lua_sethook function but I can't find a way of hooking statements.
Just set a linecount hook to execute every 1 line.
Quote: And if I were to use coroutines I would have to implement them myself in C since I don't want to enable them for the scripts I'm running.Not sure what you mean by this. Coroutines don't need to be "enabled", just used.
Quote: I like Lua, but I'm not sure that it is the best thing to us for what I'm trying to do.I don't know of any offhand.
Do you know if there is a scripting language that can be easily embedded and execute individual statements?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement