From bca47b9d70601a72cc1d6de707a2ef1cbfc8777e Mon Sep 17 00:00:00 2001 From: CST1229 <68464103+CST1229@users.noreply.github.com> Date: Wed, 24 Apr 2024 04:13:26 +0200 Subject: [PATCH] Lily/SoundExpanded: fix "change project volume" block (#1423) It used to just always set the volume to 0. This fixes it. This also makes the set volume block be clamped to 0-100 instead of being wrapped around 0-199, which I think makes more sense and is consistent with the vanilla set volume block. Though I'm not sure if it wrapping around 199 instead of 100 (or 99) was a mistake or not, or if it'll break projects. --- extensions/Lily/SoundExpanded.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/Lily/SoundExpanded.js b/extensions/Lily/SoundExpanded.js index cafbf734e5..821dffc40b 100644 --- a/extensions/Lily/SoundExpanded.js +++ b/extensions/Lily/SoundExpanded.js @@ -530,7 +530,7 @@ setProjectVolume(args) { const value = Scratch.Cast.toNumber(args.VALUE); - const newVolume = this._wrapClamp(value / 100, 0, 1); + const newVolume = Scratch.Cast.toNumber(Math.max(Math.min(value, 1), 0)); runtime.audioEngine.inputNode.gain.value = newVolume; } @@ -538,7 +538,7 @@ const value = Scratch.Cast.toNumber(args.VALUE) / 100; const volume = runtime.audioEngine.inputNode.gain.value; const newVolume = Scratch.Cast.toNumber( - Math.min(Math.max(volume + value, 1), 0) + Math.max(Math.min(volume + value, 1), 0) ); runtime.audioEngine.inputNode.gain.value = newVolume; }