public void CharacterCount(ScriptThread thread) { string haystack = thread.GetStringParameter(0); string needle = thread.GetStringParameter(1); int count = 0; for (int i = 0; i < haystack.Length; i++) if (haystack[i] == needle[0]) count++; thread.SetReturnValue(count); }
public void ExecuteFile(ScriptThread thread) { Process process = new Process(); process.StartInfo.FileName = thread.GetStringParameter(0); process.StartInfo.Arguments = thread.GetStringParameter(1); process.StartInfo.Verb = "Open"; process.StartInfo.WindowStyle = ProcessWindowStyle.Normal; process.Start(); if (thread.GetBooleanParameter(2) == true) process.WaitForExit(); }
public void Explode(ScriptThread thread) { string explodee = thread.GetStringParameter(0); char seperator = thread.GetStringParameter(1)[0]; string[] exploded = explodee.Split(new char[] { seperator }); int arrayMemoryIndex = thread.AllocateArray(DataType.String, exploded.Length); for (int i = 0; i < exploded.Length; i++) thread.SetArrayElement(arrayMemoryIndex, i, exploded[i]); thread.SetReturnValueArray(arrayMemoryIndex); }
public void CommandLineValue(ScriptThread thread) { string commandLine = thread.GetStringParameter(0); int valueIndex = thread.GetIntegerParameter(1); foreach (string arg in Engine.GlobalInstance.CommandLineArguments) { string[] value = new string[0]; string command = arg; int colonIndex = arg.IndexOf(':'); // Seperate values and command if a colon exists. if (colonIndex >= 0) { value = new string[1]; value[0] = arg.Substring(colonIndex + 1, arg.Length - colonIndex - 1); if (value[0].IndexOf(",") >= 0) value = value[0].Split(new char[1] { ',' }); command = arg.Substring(0, colonIndex); } if (command.ToLower() == commandLine.ToLower()) { if (valueIndex < 0 || valueIndex >= value.Length) { DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CommandLineValue with an invalid value index.", LogAlertLevel.Error); return; } thread.SetReturnValue(value[valueIndex]); return; } } DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CommandLineValue with a non-existant command line.", LogAlertLevel.Error); }
public void GameFlag(ScriptThread thread) { string key = thread.GetStringParameter(0).ToLower(); if (!Fusion.GlobalInstance.GameFlags.Contains(key)) return; thread.SetReturnValue((string)Fusion.GlobalInstance.GameFlags[key]); }
public void CommandLineExists(ScriptThread thread) { string commandLine = thread.GetStringParameter(0); foreach (string arg in Engine.GlobalInstance.CommandLineArguments) { string[] value = new string[0]; string command = arg; int colonIndex = arg.IndexOf(':'); // Seperate values and command if a colon exists. if (colonIndex >= 0) { value = new string[1]; value[0] = arg.Substring(colonIndex + 1, arg.Length - colonIndex - 1); if (value[0].IndexOf(",") >= 0) value = value[0].Split(new char[1] { ',' }); command = arg.Substring(0, colonIndex); } if (command.ToLower() == commandLine.ToLower()) { thread.SetReturnValue(true); return; } } thread.SetReturnValue(false); }
public void OpenStream(ScriptThread thread) { Stream stream = StreamFactory.RequestStream(thread.GetStringParameter(0), (StreamMode)thread.GetIntegerParameter(1)); if (stream == null) { DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called OpenStream with an unreachable url.", LogAlertLevel.Error); return; } thread.SetReturnValue(new StreamScriptObject(new ScriptStream(stream))); }
public void InvokeThreadFunction(ScriptThread thread) { ScriptThread actionThread = ((NativeObject)thread.GetObjectParameter(0)).Object as ScriptThread; if (actionThread == null) { DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called InvokeThreadFunction with an invalid object.", LogAlertLevel.Error); return; } actionThread.InvokeFunction(thread.GetStringParameter(1), thread.GetBooleanParameter(2), thread.GetBooleanParameter(3), false); }
public void Length(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).Length); }
public void Asc(ScriptThread thread) { thread.SetReturnValue((int)thread.GetStringParameter(0)[0]); }
public void WordWrap(ScriptThread thread) { thread.SetReturnValue(StringMethods.WordWrap(thread.GetStringParameter(0), thread.GetIntegerParameter(1))); }
public void TrimStart(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).TrimStart()); }
public void BindedKeyReleased(ScriptThread thread) { thread.SetReturnValue(InputManager.BindedKeyReleased(thread.GetStringParameter(0))); }
public void LoadLanguagePack(ScriptThread thread) { LanguageManager.LoadLanguagePack(thread.GetStringParameter(0), thread.GetStringParameter(1)); }
public void Contains(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).Contains(thread.GetStringParameter(1))); }
public void LastIndexOfB(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).LastIndexOf(thread.GetStringParameter(1), thread.GetIntegerParameter(2))); }
public void Insert(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).Insert(thread.GetIntegerParameter(2), thread.GetStringParameter(1))); }
public void ConnectToServer(ScriptThread thread) { Networking.NetworkManager.ServerIP = thread.GetStringParameter(0); if (thread.GetIntegerParameter(1) != -1) Networking.NetworkManager.Port = thread.GetIntegerParameter(1); thread.SetReturnValue(Networking.NetworkManager.Start()); }
public void DebugLogB(ScriptThread thread) { DebugLogger.WriteLog(thread.GetStringParameter(0)); }
public void DebugLogA(ScriptThread thread) { DebugLogger.WriteLog(thread.GetStringParameter(0), (LogAlertLevel)thread.GetIntegerParameter(1)); }
public void EndsWith(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).EndsWith(thread.GetStringParameter(1))); }
public void PadLeftA(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).PadLeft(thread.GetIntegerParameter(1))); }
public void IndexOfA(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).IndexOf(thread.GetStringParameter(1))); }
public void PadRightB(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).PadRight(thread.GetIntegerParameter(1), thread.GetStringParameter(2)[0])); }
public void LanguageCaptionExists(ScriptThread thread) { thread.SetReturnValue(LanguageManager.CaptionExists(thread.GetStringParameter(0))); }
public void Replace(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).Replace(thread.GetStringParameter(1), thread.GetStringParameter(2))); }
public void UnbindKey(ScriptThread thread) { InputManager.UnbindKey(thread.GetStringParameter(0)); }
public void SubstringB(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).Substring(thread.GetIntegerParameter(1), thread.GetIntegerParameter(2))); }
public void BindKey(ScriptThread thread) { InputManager.BindKey(thread.GetStringParameter(0),(KeyCodes)thread.GetIntegerParameter(1)); }
public void ToUpperCase(ScriptThread thread) { thread.SetReturnValue(thread.GetStringParameter(0).ToUpper()); }