Beispiel #1
0
            public static LuaResult require(ModuleScript module)
            {
                if (module.ReturnValue != null)
                {
                    return(module.ReturnValue);
                }

                var e = new StartExecution(module);

                try
                {
                    e.TryFulfill();

                    if (e.Result?.Count != 1)
                    {
                        throw new Exception("Module did not return exactly one value.");
                    }
                }
                catch (Exception exception)
                {
                    throw new Exception("Requested module experienced an error while loading", exception);
                }

                return(module.ReturnValue = e.Result);
            }
Beispiel #2
0
        /// <summary>
        /// Starts a script.
        /// </summary>
        public static async Task <LuaResult> ExecuteAsync(Script script, object[] args = null)
        {
            var e = new StartExecution(script, args);

            ExecutionQueue.Enqueue(e);

            await e.WaitAsync().ConfigureAwait(false);

            return(await Task.FromResult(e.Result).ConfigureAwait(false));
        }