private static bool SetVar(string command, Argument[] args, bool quiet, bool force) { if (args.Length < 1) { throw new RunTimeError(null, "Usage: setvar ('variable')"); } string varname = args[0].AsString(); ScriptVariables.ScriptVariable var = ScriptVariables.GetVariable(varname); if (var == null) { throw new RunTimeError(null, $"Unknown variable '{varname}'"); } if (!ScriptManager.SetVariableActive) { var.SetTarget(); ScriptManager.SetVariableActive = true; return(false); } if (var.TargetWasSet) { ScriptManager.SetVariableActive = false; return(true); } return(false); }
private static bool SetVar(string command, Variable[] vars, bool quiet, bool force) { if (vars.Length < 1) { throw new RunTimeError("Usage: setvar ('variable') [timeout]"); } string varname = vars[0].AsString(); ScriptVariables.ScriptVariable variable = ScriptVariables.GetVariable(varname); if (variable == null) { World.Player.SendMessage(Config.GetInt("SysColor"), $"'{varname}' not found, creating new variable"); variable = new ScriptVariables.ScriptVariable(varname, new TargetInfo()); ScriptVariables.ScriptVariableList.Add(variable); ScriptVariables.RegisterVariable(varname); ScriptManager.RedrawScriptVariables(); } Interpreter.Timeout(vars.Length == 2 ? vars[1].AsUInt() : 30000, () => { return(true); }); if (!ScriptManager.SetVariableActive) { variable.SetTarget(); ScriptManager.SetVariableActive = true; return(false); } if (variable.TargetWasSet) { Interpreter.ClearTimeout(); ScriptManager.SetVariableActive = false; return(true); } return(false); }
private static bool SetVar(string command, Argument[] args, bool quiet, bool force) { if (args.Length < 1) { throw new RunTimeError(null, "Usage: setvar ('variable') [timeout]"); } string varname = args[0].AsString(); ScriptVariables.ScriptVariable var = ScriptVariables.GetVariable(varname); if (var == null) { throw new RunTimeError(null, $"{command} - Unknown variable '{varname}'"); } Interpreter.Timeout(args.Length == 2 ? args[1].AsUInt() : 30000, () => { return(true); }); if (!ScriptManager.SetVariableActive) { var.SetTarget(); ScriptManager.SetVariableActive = true; return(false); } if (var.TargetWasSet) { Interpreter.ClearTimeout(); ScriptManager.SetVariableActive = false; return(true); } return(false); }