From f60f862c5bcb4bfc8c6dd1690739afcf759c192f Mon Sep 17 00:00:00 2001 From: ruri Date: Sat, 4 May 2019 19:47:07 +0200 Subject: [PATCH] Added the ability to use lists and dictionaries without indices to obtain their string representation (e.g. typing will print [a,b]). --- RuriLib/Blocks/BlockBase.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/RuriLib/Blocks/BlockBase.cs b/RuriLib/Blocks/BlockBase.cs index 892a77c..889ccda 100644 --- a/RuriLib/Blocks/BlockBase.cs +++ b/RuriLib/Blocks/BlockBase.cs @@ -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; } }