public static void LoadGameMode(string Name) { Directory ModeDir = new Directory(); if (ModeDir.DirExists("user://GameModes/" + Name)) //Gamemode exists { GamemodeName = Name; if (ModeDir.FileExists("user://GameModes/" + Name + "/Server.js")) //Has a server side script { SetupServerEngine(); File ServerScript = new File(); ServerScript.Open("user://GameModes/" + Name + "/Server.js", 1); ServerGmEngine.Execute(ServerScript.GetAsText()); ServerScript.Close(); } if (ModeDir.FileExists("user://GameModes/" + Name + "/Client.js")) //Has a server side script { SetupClientEngine(); File ClientScriptFile = new File(); ClientScriptFile.Open("user://GameModes/" + Name + "/Client.js", 1); ClientGmScript = ClientScriptFile.GetAsText(); ClientScriptFile.Close(); ClientGmEngine.Execute(ClientGmScript); Self.Rpc(nameof(NetLoadClientScript), new object[] { ClientGmScript }); } if (ModeDir.FileExists("user://GameModes/" + Name + "/Client.js")) //Has a client side script { } } }
public object InstallBundle(Jurassic.ScriptEngine engine) { //engine.Execute(ObjectPrototype); engine.Execute(JRClass); engine.Execute(Fiber); return(Null.Value); }
public object InstallBundle(Jurassic.ScriptEngine engine) { engine.Execute(Barista.Properties.Resources.jsonDataHandler); engine.Execute(Barista.Properties.Resources.Automapper); engine.SetGlobalValue("JsonMergeSettings", new JsonMergeSettingsConstructor(engine)); engine.SetGlobalValue("JsonSchema", new JsonSchemaConstructor(engine)); engine.Object.InstancePrototype.SetPropertyValue("merge", new JsonData.MergeFunctionInstance(engine, engine.Object.InstancePrototype), false); engine.Object.InstancePrototype.SetPropertyValue("selectToken", new JsonData.SelectTokenFunctionInstance(engine, engine.Object.InstancePrototype), false); engine.Object.InstancePrototype.SetPropertyValue("selectTokens", new JsonData.SelectTokensFunctionInstance(engine, engine.Object.InstancePrototype), false); engine.Object.InstancePrototype.SetPropertyValue("isValid", new JsonData.IsValidFunctionInstance(engine, engine.Object.InstancePrototype), false); engine.Object.InstancePrototype.SetPropertyValue("isValid2", new JsonData.IsValid2FunctionInstance(engine, engine.Object.InstancePrototype), false); return(Null.Value); }
public void Construct(params string[] JavascriptSourceFiles) { JurassicEngine = new Jurassic.ScriptEngine(); foreach (string JavascriptSourceFile in JavascriptSourceFiles) { JurassicEngine.ExecuteFile(JavascriptSourceFile); } JurassicEngine.Execute("var Parse = function (strCDL) " + "{ return grammarAst.parse(strCDL); };"); }
public override void _Ready() { File SetupScript = new File(); SetupScript.Open("res://Scripting/SetupScript.js", 1); ConsoleEngine.Execute(SetupScript.GetAsText()); SetupScript.Close(); File Autoexec = new File(); if (Autoexec.FileExists("user://autoexec.js")) { Autoexec.Open("user://autoexec.js", 1); Console.Print("Autoexec loaded 'autoexec.js'"); try { ConsoleEngine.Execute(Autoexec.GetAsText()); } catch (JavaScriptException Error) { Console.Print(Error.Message + " @ line " + Error.LineNumber.ToString()); Console.Print("AUTOEXEC FAILED: Not all parts of the autoexec executed successfully. It is highly recommended that you fix your autoexec and restart the game."); } } else { Console.Print("Autoexec not found 'autoexec.js'"); } Autoexec.Close(); string[] CmdArgs = OS.GetCmdlineArgs(); foreach (string CurrentArg in CmdArgs) { Console.Log("Command line argument '" + CurrentArg + "'"); if (CurrentArg == "-dev_connect") { Console.Execute("connect();"); } } }
private void bw_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; string work = e.Argument as string; int tm = 31; System.Net.WebClient wc = new System.Net.WebClient(); wc.Encoding = System.Text.Encoding.UTF8; wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_jsCompleted); try { wc.DownloadStringAsync(new Uri(work)); } catch { this.value = "Could not open script: " + work; tm = 0; } //js = "function onmessage(s){s='Child got: '+s;workermessage(s);}var i=1000000;var m=0;var o=[];while(i>0){i=i-1;m=Math.floor(Math.ceil(Math.random()*1000000)/(Math.ceil(Math.random()*1000)+1));if(m%19==0){o.push(m);}}workermessage(o.join(', '));workercompleted('done!');"; while (0<--tm) { if (worker.CancellationPending == true) { e.Cancel = true; js = ""; break; } else if(js.Length>0) { break; } Thread.Sleep(1000); } if (js.Length > 0) { var engine = new Jurassic.ScriptEngine(); MethodInfo mi1 = typeof(MainPage).GetMethod("message", BindingFlags.Public | BindingFlags.Instance); Delegate del1 = Delegate.CreateDelegate(typeof(msg), this, mi1, true); ; MethodInfo mi2 = typeof(MainPage).GetMethod("complete", BindingFlags.Public | BindingFlags.Instance); Delegate del2 = Delegate.CreateDelegate(typeof(msg), this, mi2, true); engine.SetGlobalFunction(this.onworkermessage, del1); engine.SetGlobalFunction(this.onworkercompleted, del2); engine.Execute(js); tm = Int32.Parse(this.timeout); while (0 < --tm) { if(this.msg.Length>0) { //send a message to the worker engine.CallGlobalFunction("onmessage", this.msg); this.msg = ""; } else if (worker.CancellationPending == true) { e.Cancel = true; break; } else if (this.completed == true) { break; } Thread.Sleep(1000); } } }
private static ScriptEngine BuildJsEnvironment() { var js = new Jurassic.ScriptEngine(); js.Execute(Resources.coffeescript); return js; }
public object InstallBundle(Jurassic.ScriptEngine engine) { engine.Execute(Barista.Properties.Resources.moment_min); return(Null.Value); }
private void injectJson(string json) { string javascript = string.Format("{0} = {1};", JSON_OBJ_NAME, json); _engine.Execute(javascript); }
public object InstallBundle(Jurassic.ScriptEngine engine) { engine.Execute(LinqScriptSource); return(Null.Value); }