LuaGetGlobal() public static method

public static LuaGetGlobal ( LuaState L, CharPtr s ) : void
L LuaState
s CharPtr
return void
コード例 #1
0
        static void dotty(LuaState L)
        {
            int     status;
            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.LuaGetTop(L) > 0)
                {                  /* any result to print? */
                    Lua.LuaGetGlobal(L, "print");
                    Lua.LuaInsert(L, 1);
                    if (Lua.LuaPCall(L, Lua.LuaGetTop(L) - 1, 0, 0) != 0)
                    {
                        l_message(progname, Lua.LuaPushFString(L,
                                                               "error calling " + Lua.LUA_QL("print").ToString() + " (%s)",
                                                               Lua.LuaToString(L, -1)));
                    }
                }
            }
            Lua.LuaSetTop(L, 0);              /* clear stack */
            Lua.fputs("\n", Lua.stdout);
            Lua.fflush(Lua.stdout);
            progname = oldprogname;
        }
コード例 #2
0
 static int dolibrary(LuaState L, CharPtr name)
 {
     Lua.LuaGetGlobal(L, "require");
     Lua.LuaPushString(L, name);
     return(report(L, docall(L, 1, 1)));
 }