Fixed an issue where the Parse Block was adding an empty element to list variables.

This commit is contained in:
ruri
2019-05-05 01:08:38 +02:00
parent f60f862c5b
commit 233d014035
+3 -1
View File
@@ -289,7 +289,9 @@ namespace RuriLib
/// <param name="suffix">The string to add at the end of the value</param>
public static void InsertVariables(BotData data, bool isCapture, bool recursive, List<string> values, string variableName, string prefix, string suffix)
{
var list = values.Select(v => ReplaceValues(prefix, data) + v.Trim() + ReplaceValues(suffix, data));
var list = values
.Where(v => !string.IsNullOrEmpty(v)) // Remove the empty entries, e.g. the one added by default by the Parse Block
.Select(v => ReplaceValues(prefix, data) + v.Trim() + ReplaceValues(suffix, data));
CVar variable;
if (recursive) variable = new CVar(variableName, list.ToList(), isCapture);
else variable = new CVar(variableName, list.First(), isCapture);