Esempio n. 1
0
 /// <summary>
 /// Creates a coroutine pointing at the specified function.
 /// </summary>
 /// <param name="function">The function.</param>
 /// <returns>
 /// The coroutine handle.
 /// </returns>
 /// <exception cref="System.ArgumentException">Thrown if function is not of DataType.Function or DataType.ClrFunction</exception>
 public DynValue CreateCoroutine(object function)
 {
     return(CreateCoroutine(DynValue.FromObject(this, function)));
 }
Esempio n. 2
0
        /// <summary>
        /// Creates a new dynamic expression which is actually quite static, returning always the same constant value.
        /// </summary>
        /// <param name="code">The code of the not-so-dynamic expression.</param>
        /// <param name="constant">The constant to return.</param>
        /// <returns></returns>
        public DynamicExpression CreateConstantDynamicExpression(string code, DynValue constant)
        {
            this.CheckScriptOwnership(constant);

            return(new DynamicExpression(this, code, constant));
        }
Esempio n. 3
0
 /// <summary>
 /// Calls the specified function.
 /// </summary>
 /// <param name="function">The Lua/MoonSharp function to be called </param>
 /// <param name="args">The arguments to pass to the function.</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentException">Thrown if function is not of DataType.Function</exception>
 public DynValue Call(object function, params object[] args)
 {
     return(Call(DynValue.FromObject(this, function), args));
 }
Esempio n. 4
0
 /// <summary>
 /// Calls the specified function.
 /// </summary>
 /// <param name="function">The Lua/MoonSharp function to be called</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentException">Thrown if function is not of DataType.Function</exception>
 public DynValue Call(object function)
 {
     return(Call(DynValue.FromObject(this, function)));
 }
Esempio n. 5
0
 /// <summary>
 /// Calls the specified function.
 /// </summary>
 /// <param name="function">The Lua/MoonSharp function to be called</param>
 /// <returns>
 /// The return value(s) of the function call.
 /// </returns>
 /// <exception cref="System.ArgumentException">Thrown if function is not of DataType.Function</exception>
 public DynValue Call(DynValue function)
 {
     return(Call(function, new DynValue[0]));
 }
Esempio n. 6
0
        /// <summary>
        /// Loads and executes a file containing a Lua/MoonSharp script.
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <param name="globalContext">The global context.</param>
        /// <param name="codeFriendlyName">Name of the code - used to report errors, etc. Also used by debuggers to locate the original source file.</param>
        /// <returns>
        /// A DynValue containing the result of the processing of the loaded chunk.
        /// </returns>
        public DynValue DoFile(string filename, Table globalContext = null, string codeFriendlyName = null)
        {
            DynValue func = LoadFile(filename, globalContext, codeFriendlyName);

            return(Call(func));
        }
Esempio n. 7
0
        /// <summary>
        /// Loads and executes a stream containing a Lua/MoonSharp script.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="globalContext">The global context.</param>
        /// <param name="codeFriendlyName">Name of the code - used to report errors, etc. Also used by debuggers to locate the original source file.</param>
        /// <returns>
        /// A DynValue containing the result of the processing of the loaded chunk.
        /// </returns>
        public DynValue DoStream(Stream stream, Table globalContext = null, string codeFriendlyName = null)
        {
            DynValue func = LoadStream(stream, globalContext, codeFriendlyName);

            return(Call(func));
        }