[SDL] Re: SDL + LUA
E. Wing
ewmailing at gmail.com
Mon Jan 23 13:12:37 PST 2006
> From: "Ferran Ferri" <ferranferri at yahoo.es>
> lua_baselibopen(ls);
> if (lua_dofile(ls,"script.lua")==1) {
> log->Write(COLOR_RED,"Unable to load script");
> exit(0);
> }
>
> Where the lua script has lines refered to console like print("Hello"). I
> suppose that the error is because the lua can access to console as the
> application is SDL based.
As I said, I don't think this is supposed to be a problem. I actually
do this all the time in my own code.
So again, in your C/C++ code, what happens if you call
printf("Hello);? Does it also hang?
What if you completely remove your current script and replace it with
a single line of code?
print("Hello")
What happens if you replace this single line of code with:
foo = 1+1
(so there are no I/O calls)
What if you create your own new C print function and register it with
your lua script and use that instead? (Typed in mail so beware)
/* Crappy print that only prints one string */
static int my_print(lua_State* L)
{
printf("%s\n", lua_tostring(L, -1);
return 0;
}
// Somewhere in your setup code
lua_pushcfunction(ls, my_print);
lua_setglobal(ls, "myprint");
-- In Lua code
print = myprint; -- override the default print if you want
myprint("hello")
-Eric
More information about the SDL
mailing list