added option to not always randomize json arrays

This commit is contained in:
2022-11-30 00:49:59 +01:00
parent f0bf7b1966
commit c01a20e603

View File

@@ -15,15 +15,10 @@ public partial class dialog_trigger_area : Area2D
var jsonFile = JSON.ParseString(text); var jsonFile = JSON.ParseString(text);
Dictionary allDialog = (Dictionary)jsonFile; Dictionary allDialog = (Dictionary)jsonFile;
try if (currentKey.BeginsWith("random")) {
{
string[] dialogPart = allDialog[currentKey].AsStringArray(); string[] dialogPart = allDialog[currentKey].AsStringArray();
GD.Print(dialogPart[GD.Randi() % dialogPart.Length]); GD.Print(dialogPart[GD.Randi() % dialogPart.Length]);
} } else GD.Print(allDialog[currentKey]);
catch
{
GD.Print(allDialog[currentKey]);
}
} }
} }