예제 #1
0
        /// <summary>
        /// Creates a MoonSharp script with bindings
        /// </summary>
        /// <param name="bindings"></param>
        /// <returns></returns>
        public static Script CreateBoundScript(ScriptBindings bindings = null, CoreModules modules = CoreModules.Preset_HardSandbox | CoreModules.Coroutine | CoreModules.OS_Time)
        {
            Script script = new Script(modules);

            GlobalScriptBindings.Initialize(script);
            bindings.Initialize(script);
            return(script);
        }
 public HookedScriptRunner()
 {
     Lua = new Script(CoreModules.Preset_HardSandbox | CoreModules.Coroutine | CoreModules.OS_Time);
     Lua.Globals["Script"]            = new ScriptReference(Lua);
     Lua.Globals["RegisterHook"]      = (Action <DynValue, string>)RegisterHook;
     Lua.Globals["RegisterCoroutine"] = (Action <DynValue, string, bool>)RegisterCoroutine;
     Lua.Globals["RemoveHook"]        = (Action <string>)RemoveHook;
     //Global init
     GlobalScriptBindings.Initialize(Lua);
 }
예제 #3
0
        private void Initialize()
        {
            Lua = new Script(CoreModules.Preset_HardSandbox | CoreModules.Coroutine | CoreModules.OS_Time);
            Lua.Globals["Script"]            = new ScriptReference(Lua);
            Lua.Globals["RegisterHook"]      = (Action <DynValue, string>)RegisterHook;
            Lua.Globals["RegisterCoroutine"] = (Action <DynValue, string, bool>)RegisterCoroutine;
            Lua.Globals["RemoveHook"]        = (Action <string>)RemoveHook;
            Lua.Globals["MakeGlobal"]        = (Action <string>)MakeGlobal;
            Lua.Globals["RemoveGlobal"]      = (Action <string>)RemoveGlobal;
            Lua.Globals["ResetGlobals"]      = (Action)ResetGlobals;

            GlobalScriptBindings.Initialize(Lua);
        }
 /// <summary>
 /// Creates a new HookedScriptRunner with the specified modules, throws exception if Coroutines flag is not included
 /// </summary>
 /// <param name="modules"></param>
 public HookedScriptRunner(CoreModules modules)
 {
     if (!modules.HasFlag(CoreModules.Coroutine))
     {
         throw new ArgumentException("Modules must contain the Coroutine Flag to be used in a HookedScriptRunner", "modules");
     }
     Lua = new Script(modules);
     Lua.Globals["Script"]            = new ScriptReference(Lua);
     Lua.Globals["RegisterHook"]      = (Action <DynValue, string>)RegisterHook;
     Lua.Globals["RegisterCoroutine"] = (Action <DynValue, string, bool>)RegisterCoroutine;
     Lua.Globals["RemoveHook"]        = (Action <string>)RemoveHook;
     //Global init
     GlobalScriptBindings.Initialize(Lua);
 }
 public BasicScriptRunner(CoreModules modules = CoreModules.Preset_HardSandbox | CoreModules.Coroutine | CoreModules.OS_Time)
 {
     Lua = new Script(modules);
     Lua.Globals["Script"] = new ScriptReference(Lua);
     GlobalScriptBindings.Initialize(Lua);
 }