diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 9488bd9f50..97d7e72411 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -2563,6 +2563,8 @@ unitlocate.outx = Output X coordinate. unitlocate.outy = Output Y coordinate. unitlocate.group = Building group to look for. +playsound.limit = If true, prevents this sound from playing\nif it has already been played in the same frame. + lenum.idle = Don't move, but keep building/mining.\nThe default state. lenum.stop = Stop moving/mining/building. lenum.unbind = Completely disable logic control.\nResume standard AI. diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index 4a977b3dcd..f57cdffc9e 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -1919,12 +1919,12 @@ public class LExecutor{ public static class PlaySoundI implements LInstruction{ public boolean positional; - public LVar id, volume, pitch, pan, x, y; + public LVar id, volume, pitch, pan, x, y, limit; public PlaySoundI(){ } - public PlaySoundI(boolean positional, LVar id, LVar volume, LVar pitch, LVar pan, LVar x, LVar y){ + public PlaySoundI(boolean positional, LVar id, LVar volume, LVar pitch, LVar pan, LVar x, LVar y, LVar limit){ this.positional = positional; this.id = id; this.volume = volume; @@ -1932,6 +1932,7 @@ public class LExecutor{ this.pan = pan; this.x = x; this.y = y; + this.limit = limit; } @Override @@ -1940,9 +1941,9 @@ public class LExecutor{ if(sound == null || sound == Sounds.swish) sound = Sounds.none; //no. if(positional){ - sound.at(World.unconv(x.numf()), World.unconv(y.numf()), pitch.numf(), Math.min(volume.numf(), 2f)); + sound.at(World.unconv(x.numf()), World.unconv(y.numf()), pitch.numf(), Math.min(volume.numf(), 2f), limit.bool()); }else{ - sound.play(Math.min(volume.numf() * (Core.settings.getInt("sfxvol") / 100f), 2f), pitch.numf(), pan.numf()); + sound.play(Math.min(volume.numf() * (Core.settings.getInt("sfxvol") / 100f), 2f), pitch.numf(), pan.numf(), false, limit.bool()); } } } diff --git a/core/src/mindustry/logic/LStatements.java b/core/src/mindustry/logic/LStatements.java index a27e35304b..b68faeaf94 100644 --- a/core/src/mindustry/logic/LStatements.java +++ b/core/src/mindustry/logic/LStatements.java @@ -2127,7 +2127,7 @@ public class LStatements{ @RegisterStatement("playsound") public static class PlaySoundStatement extends LStatement{ public boolean positional; - public String id = "@sfx-pew", volume = "1", pitch = "1", pan = "0", x = "@thisx", y = "@thisy"; + public String id = "@sfx-pew", volume = "1", pitch = "1", pan = "0", x = "@thisx", y = "@thisy", limit = "true"; @Override public void build(Table table){ @@ -2169,6 +2169,10 @@ public class LStatements{ }else{ fieldst(table, "pan", pan, str -> pan = str); } + + table.row(); + + fieldst(table, "limit", limit, str -> limit = str); } @Override @@ -2178,7 +2182,7 @@ public class LStatements{ @Override public LInstruction build(LAssembler builder){ - return new PlaySoundI(positional, builder.var(id), builder.var(volume), builder.var(pitch), builder.var(pan), builder.var(x), builder.var(y)); + return new PlaySoundI(positional, builder.var(id), builder.var(volume), builder.var(pitch), builder.var(pan), builder.var(x), builder.var(y), builder.var(limit)); } @Override