public ScriptFunction(Script scriptRef, DynValue function, bool coroutine = false, bool autoreset = true) { this.ScriptRef = scriptRef; LuaFunc = function; IsCoroutine = coroutine; AutoResetCoroutine = autoreset; Coroutine = coroutine ? scriptRef.CreateCoroutine(LuaFunc) : null; FuncType = StandardHelpers.GetLuaFuncType(coroutine, autoreset); }
/// <summary> /// Creates a script hook from a reference script and a string containing a function /// </summary> /// <param name="scriptRef">A MoonSharp script to associate this <see cref="ScriptFunction"/> with</param> /// <param name="singleFunctionString">an unnamed function string<para/>Example: "function() print('test') end"</param> /// <param name="coroutine">is it a coroutine?</param> /// <param name="autoreset">should the coroutine reset automatically?</param> public ScriptFunction(Script scriptRef, string singleFunctionString, bool coroutine = false, bool autoreset = true) { this.ScriptRef = scriptRef; LuaFunc = scriptRef.LoadFunction(singleFunctionString); IsCoroutine = coroutine; AutoResetCoroutine = autoreset; Coroutine = coroutine ? scriptRef.CreateCoroutine(LuaFunc) : null; FuncType = StandardHelpers.GetLuaFuncType(coroutine, autoreset); }
public ScriptFunction(Script scriptRef, string singleFunctionString) { this.ScriptRef = scriptRef; LuaFunc = scriptRef.LoadFunction(singleFunctionString); IsCoroutine = false; AutoResetCoroutine = false; Coroutine = null; FuncType = StandardHelpers.GetLuaFuncType(false, false); }