Inheritance: MonoBehaviour
Esempio n. 1
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;
        }
Esempio n. 2
0
 protected virtual void Bind()
 {
     LuaBinder.Bind(luaState);
     LuaCoroutine.Register(luaState, this);
 }
Esempio n. 3
0
 protected virtual void Bind()
 {
     LuaBinder.Bind(luaState);
     DelegateFactory.Init();
     LuaCoroutine.Register(luaState, this);
 }
Esempio n. 4
0
 void InitLuaBind()
 {
     LuaBinder.Bind(luaState);
     LuaCoroutine.Register(luaState, this);
 }
Esempio n. 5
0
 protected virtual void Bind()
 {
     LuaBinder.Bind(m_LuaState);
     DelegateFactory.Init();
     LuaCoroutine.Register(m_LuaState, ANF.Core.Mgr.Coroutine);
 }
 private void Bind()
 {
     LuaBinder.Bind(m_LuaState);
     LuaCoroutine.Register(m_LuaState, this);
 }
Esempio n. 7
0
        private CPUUpdateResult ReallyBoot(LuaMount bootMount)
        {
            if (m_machine != null)
            {
                throw new InvalidOperationException();
            }

            // Check if the system has any RAM
            if (m_computer.Memory.TotalMemory == 0)
            {
                m_computer.ErrorOutput.WriteLine("Error starting CPU: No RAM");
                return(m_isMainCPU ? CPUUpdateResult.Shutdown : CPUUpdateResult.Continue);
            }

            // Mount the ROM
            m_fileSystem.Mount(bootMount, FilePath.Empty, FilePath.Empty, true);

            // Check if the boot path exists
            var bootPath = new FilePath("boot.lua");

            if (!m_fileSystem.Exists(bootPath) || m_fileSystem.IsDir(bootPath))
            {
                m_computer.ErrorOutput.WriteLine("Error starting CPU: ROM does not countain {0}", bootPath);
                m_fileSystem.UnmountAll();
                return(m_isMainCPU ? CPUUpdateResult.Shutdown : CPUUpdateResult.Continue);
            }

            // Init lua machine
            m_machine = new LuaMachine(m_computer.Memory);
            m_machine.AllowByteCodeLoading = false;
            m_machine.EnforceTimeLimits    = true;
            try
            {
                // Remove default APIs we don't want
                m_machine.RemoveUnsafeGlobals();

                // Install basic APIs
                if (m_computer.Host != null)
                {
                    m_machine.SetGlobal("_HOST", m_computer.Host);
                }
                InstallAPI(new IOAPI(m_computer, m_fileSystem));
                InstallAPI(new OSAPI(m_computer, this, m_fileSystem));
                InstallAPI(new PackageAPI(m_computer, m_fileSystem));

                // Install custom APIs
                PreloadAPI(new SystemAPI(m_computer, this));
                PreloadAPI(new FSAPI(m_computer, m_fileSystem));
            }
            catch (LuaError e)
            {
                m_computer.ErrorOutput.WriteLine("Error starting CPU: {0}", e.Message);
                Halt();
                return(m_isMainCPU ? CPUUpdateResult.Shutdown : CPUUpdateResult.Continue);
            }

            // Load the boot script
            try
            {
                string bootScript;
                using (var reader = m_fileSystem.OpenForRead(bootPath))
                {
                    bootScript = reader.ReadToEnd();
                }
                var bootFunction = m_machine.LoadString(bootScript, "@" + bootPath);
                m_mainRoutine = m_machine.CreateCoroutine(bootFunction);
                m_eventFilter.Clear();
            }
            catch (IOException e)
            {
                m_computer.ErrorOutput.WriteLine("Error loading {0}: {1}", bootPath, e.Message);
                Halt();
                return(m_isMainCPU ? CPUUpdateResult.Shutdown : CPUUpdateResult.Continue);
            }
            catch (LuaError e)
            {
                m_computer.ErrorOutput.WriteLine("Error parsing {0}: {1}", bootPath, e.Message);
                Halt();
                return(m_isMainCPU ? CPUUpdateResult.Shutdown : CPUUpdateResult.Continue);
            }

            // Start the boot script
            m_eventFilter.Clear();
            return(Resume(LuaArgs.Empty));
        }
Esempio n. 8
0
        public static LuaValue Status(LuaValue[] args)
        {
            LuaCoroutine c = args[0] as LuaCoroutine;

            return(new LuaString(c.Status));
        }
Esempio n. 9
0
 void Start()
 {
     LuaCoroutine.Register(LuaManager.Instance.lua, this);
     loop          = gameObject.AddComponent <LuaLooper>();
     loop.luaState = LuaManager.Instance.lua;
 }
Esempio n. 10
0
 void Awake()
 {
     Init();
     LuaCoroutine.Register(lua, this);
 }