Exemple #1
0
    public Lua()
    {
        LuaState.loaderDelegate += luaLoader;
        luaState = new LuaState();

        //  LuaDLL.lua_pushstdcallcfunction(luaState.L, import);
        //LuaDLL.lua_setglobal(luaState.L, "using");

        LuaObject.init(luaState.L);
        bindAll(luaState.L);

        GameObject go = new GameObject("LuaSvrProxy");

        lgo = go.AddComponent <LuaSvrGameObject>();
        GameObject.DontDestroyOnLoad(go);
        lgo.state    = luaState;
        lgo.onUpdate = this.tick;

        LuaTimer.reg(luaState.L);
        LuaCoroutine.reg(luaState.L, lgo);
        Helper.reg(luaState.L);
        LuaValueType.reg(luaState.L);
        LuaDLL.luaS_openextlibs(luaState.L);

        /*
         * if (LuaDLL.lua_gettop(luaState.L) != errorReported)
         * {
         *  Debug.LogError("Some function not remove temp value from lua stack. You should fix it.");
         *  errorReported = LuaDLL.lua_gettop(luaState.L);
         * }
         * */
    }
Exemple #2
0
        void doinit(IntPtr L)
        {
            // LuaTimer.reg(L);
            LuaCoroutine.reg(L, lgo);
            Helper.reg(L);
            LuaValueType.reg(L);
            SLuaDebug.reg(L);
            LuaUtils.reg(luaState.L);

            lgo.state    = luaState;
            lgo.onUpdate = this.tick;
            lgo.init();

            LuaState.errorDelegate = delegate(string msg) {
                errorDelegate(msg);
            };

            inited = true;
        }
Exemple #3
0
        private void _doinit(IntPtr _luaState, LuaSvrFlag _flag)
        {
            //LuaTimer.reg( _luaState );
#if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isPlaying)
#endif
            LuaCoroutine.reg(_luaState, this);
            SLua.Helper.reg(_luaState);
            if (SLuaSetting.Instance.useLuaValueType)
            {
                LuaValueType.reg(_luaState);
            }

            if ((_flag & LuaSvrFlag.LSF_EXTLIB) != 0)
            {
                LuaDLL.luaS_openextlibs(_luaState);
            }
            if ((_flag & LuaSvrFlag.LSF_3RDDLL) != 0)
            {
                Lua3rdDLL.open(_luaState);
            }

            Inited = true;
        }