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, 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); }