Exemplo 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)));
 }
Exemplo 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));
        }
Exemplo 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));
 }
Exemplo 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)));
 }
Exemplo 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]));
 }
Exemplo 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));
        }
Exemplo 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));
        }