29 using System.Collections.Generic;
32 using System.Reflection;
36 namespace OpenSim.Framework.Console
42 public const int LocalIdNotFound = 0;
48 public const string CoordHelp
49 =
@"Each component of the coord is comma separated. There must be no spaces between the commas.
50 If you don't care about the z component you can simply omit it.
51 If you don't care about the x or y components then you can leave them blank (though a comma is still required)
52 If you want to specify the maximum value of a component then you can use ~ instead of a number
53 If you want to specify the minimum value of a component then you can use -~ instead of a number
55 show object pos 20,20,20 to 40,40,40
56 delete object pos 20,20 to 40,40
57 show object pos ,20,20 to ,40,40
58 delete object pos ,,30 to ,,~
59 show object pos ,,-~ to ,,30";
61 public const string MinRawConsoleVectorValue =
"-~";
62 public const string MaxRawConsoleVectorValue =
"~";
64 public const string VectorSeparator =
",";
65 public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
76 if (
File.Exists(path))
78 console.OutputFormat(
"File {0} already exists. Please move or remove it.", path);
97 if (!UUID.TryParse(rawUuid, out uuid))
100 console.OutputFormat(
"ERROR: {0} is not a valid uuid", rawUuid);
110 if (!uint.TryParse(rawLocalId, out localId))
113 console.OutputFormat(
"ERROR: {0} is not a valid local id", localId);
121 console.OutputFormat(
"ERROR: {0} is not a valid local id - it must be greater than 0", localId);
141 if (TryParseConsoleUuid(null, rawId, out uuid))
143 localId = LocalIdNotFound;
147 if (TryParseConsoleLocalId(null, rawId, out localId))
153 console.OutputFormat(
"ERROR: {0} is not a valid UUID or local id", rawId);
167 if (!
bool.TryParse(rawConsoleString, out b))
170 console.OutputFormat(
"ERROR: {0} is not a true or false value", rawConsoleString);
187 if (!
int.TryParse(rawConsoleInt, out i))
190 console.OutputFormat(
"ERROR: {0} is not a valid integer", rawConsoleInt);
207 if (!
float.TryParse(rawConsoleInput, out i))
210 console.OutputFormat(
"ERROR: {0} is not a valid float", rawConsoleInput);
227 if (!
double.TryParse(rawConsoleInput, out i))
230 console.OutputFormat(
"ERROR: {0} is not a valid double", rawConsoleInput);
247 if (TryParseConsoleInt(console, rawConsoleInt, out i))
252 console.OutputFormat(
"ERROR: {0} is not a positive integer", rawConsoleInt);
271 return TryParseConsoleVector(rawConsoleVector, c =>
float.MinValue.ToString(), out
vector);
282 return TryParseConsoleVector(rawConsoleVector, c =>
float.MaxValue.ToString(), out
vector);
301 string rawConsoleVector, Func<string, string> blankComponentFunc, out Vector3
vector)
303 return Vector3.TryParse(CookVector(rawConsoleVector, 3, blankComponentFunc), out
vector);
322 string rawConsoleVector, Func<string, string> blankComponentFunc, out Vector2
vector)
326 string cookedVector = CookVector(rawConsoleVector, 2, blankComponentFunc);
328 if (cookedVector == null)
330 vector = Vector2.Zero;
336 string[] cookedComponents = cookedVector.Split(VectorSeparatorChars);
338 vector =
new Vector2(
float.Parse(cookedComponents[0]),
float.Parse(cookedComponents[1]));
353 private static string CookVector(
354 string rawConsoleVector,
int dimensions, Func<string, string> blankComponentFunc)
356 List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
358 if (components.Count < 1 || components.Count > dimensions)
361 if (components.Count < dimensions)
363 if (blankComponentFunc == null)
366 for (
int i = components.Count; i < dimensions; i++)
370 List<string> cookedComponents
371 = components.ConvertAll<
string>(
375 return blankComponentFunc.Invoke(c);
376 else if (c == MaxRawConsoleVectorValue)
377 return float.MaxValue.ToString();
378 else if (c == MinRawConsoleVectorValue)
379 return float.MinValue.ToString();
384 return string.Join(VectorSeparator, cookedComponents.ToArray());
static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector)
Convert a maximum vector input from the console to an OpenMetaverse.Vector3
static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector)
Convert a minimum vector input from the console to an OpenMetaverse.Vector3
static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid)
Try to parse a console UUID from the console.
static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i)
Convert a console input to an int, automatically complaining if a console is given.
static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId)
Tries to parse the input as either a UUID or a local ID.
static bool TryParseConsoleVector(string rawConsoleVector, Func< string, string > blankComponentFunc, out Vector3 vector)
Convert a vector input from the console to an OpenMetaverse.Vector3
static bool TryParseConsoleDouble(ICommandConsole console, string rawConsoleInput, out double i)
Convert a console input to a double, automatically complaining if a console is given.
static bool TryParseConsoleBool(ICommandConsole console, string rawConsoleString, out bool b)
Convert a console input to a bool, automatically complaining if a console is given.
static bool TryParseConsole2DVector(string rawConsoleVector, Func< string, string > blankComponentFunc, out Vector2 vector)
Convert a vector input from the console to an OpenMetaverse.Vector2
static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId)
static bool TryParseConsoleFloat(ICommandConsole console, string rawConsoleInput, out float i)
Convert a console input to a float, automatically complaining if a console is given.
static bool TryParseConsoleNaturalInt(ICommandConsole console, string rawConsoleInt, out int i)
Convert a console integer to a natural int, automatically complaining if a console is given...
static bool CheckFileDoesNotExist(ICommandConsole console, string path)
Check if the given file path exists.
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3 vector