From 2ad38fc3b080288af7e21a2d0effd87adf315f70 Mon Sep 17 00:00:00 2001 From: JeanJPNM <61994401+JeanJPNM@users.noreply.github.com> Date: Tue, 6 Aug 2024 21:27:25 -0300 Subject: [PATCH] Fix the sfx selection gui for playsound (#10095) * fix the index used to get the sfx substring * handle cases where the sxf variable is not a built-in This prevents a crash that happened whenever the sfx variable's name had less than 5 characters (4 before this pr), since the substring method was called regardless of the name's size. --- core/src/mindustry/logic/LStatements.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/logic/LStatements.java b/core/src/mindustry/logic/LStatements.java index b68faeaf94..9d8faa880a 100644 --- a/core/src/mindustry/logic/LStatements.java +++ b/core/src/mindustry/logic/LStatements.java @@ -2149,7 +2149,8 @@ public class LStatements{ table.button(b -> { b.image(Icon.pencilSmall); - b.clicked(() -> showSelect(b, GlobalVars.soundNames.toArray(String.class), id.substring(4), t -> { + String soundName = id.startsWith("@sfx-") ? id.substring(5) : id; + b.clicked(() -> showSelect(b, GlobalVars.soundNames.toArray(String.class), soundName, t -> { id = "@sfx-" + t; rebuild(table); }, 2, cell -> cell.size(160, 50)));