fix random array index out of range

This commit is contained in:
2023-02-07 21:11:22 +01:00
parent 6ee9a3cecd
commit cf307869d6

View File

@@ -27,7 +27,7 @@ public partial class dialog_bubble : CanvasLayer
{
dlgLines = parsedDlg.AsGodotDictionary()[key].AsGodotArray();
if (dlgLines.VariantType == Variant.Type.Array)
dlgLines = dlgLines.AsGodotArray()[GD.RandRange(0, dlgLines.AsGodotArray().Count)];
dlgLines = dlgLines.AsGodotArray()[GD.RandRange(0, dlgLines.AsGodotArray().Count - 1)];
}
public void CloseDialog()
@@ -60,7 +60,6 @@ public partial class dialog_bubble : CanvasLayer
GetNode<PanelContainer>("box/panel_container").Visible = true;
}
}
if (dlgLines.AsGodotArray()[dlgPointer].VariantType != Variant.Type.Dictionary)
dlgPointer++;
}
if (richText.VisibleCharacters < Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length && GetNode<Timer>("typewriter_timer").IsStopped())