Added the ability to use lists and dictionaries without indices to obtain their string representation (e.g. typing <LIST123> will print [a,b]).

This commit is contained in:
ruri
2019-05-04 19:47:07 +02:00
parent 1aff26e3c8
commit f60f862c5b
+14
View File
@@ -211,6 +211,14 @@ namespace RuriLib
break;
case CVar.VarType.List:
// If it's just the list name, replace it with its string representation
if (string.IsNullOrEmpty(args))
{
output = output.Replace(full, v.ToString());
break;
}
var index = 0;
int.TryParse(ParseArguments(args, '[', ']')[0], out index);
var item = v.GetListItem(index); // Can return null
@@ -218,6 +226,7 @@ namespace RuriLib
break;
case CVar.VarType.Dictionary:
if (args.Contains("(") && args.Contains(")"))
{
var dicKey = ParseArguments(args, '(', ')')[0];
@@ -228,6 +237,11 @@ namespace RuriLib
var dicVal = ParseArguments(args, '{', '}')[0];
try { output = output.Replace(full, v.GetDictKey(dicVal)); } catch { }
}
else // If it's just the dictionary name, replace it with its string representation
{
output = output.Replace(full, v.ToString());
break;
}
break;
}
}