Пример #1
0
        static void dotty(Lua.LuaState L)
        {
            int status;

            Lua.CharPtr oldprogname = progname;
            progname = null;
            while ((status = loadline(L)) != -1)
            {
                if (status == 0)
                {
                    status = docall(L, 0, 0);
                }
                report(L, status);
                if (status == 0 && Lua.lua_gettop(L) > 0)
                {  /* any result to print? */
                    Lua.lua_getglobal(L, "print");
                    Lua.lua_insert(L, 1);
                    if (Lua.lua_pcall(L, Lua.lua_gettop(L) - 1, 0, 0) != 0)
                    {
                        l_message(progname, Lua.lua_pushfstring(L,
                                                                "error calling " + Lua.LUA_QL("print").ToString() + " (%s)",
                                                                Lua.lua_tostring(L, -1)));
                    }
                }
            }
            Lua.lua_settop(L, 0);  /* clear stack */
            Lua.fputs("\n", Lua.stdout);
            Lua.fflush(Lua.stdout);
            progname = oldprogname;
        }
Пример #2
0
 static int dolibrary(Lua.LuaState L, Lua.CharPtr name)
 {
     Lua.lua_getglobal(L, "require");
     Lua.lua_pushstring(L, name);
     return(report(L, docall(L, 1, 1)));
 }