i have an ingame which should play music even when you don’t listen to it, but upon tuning to a frequency only the first sound plays, the other ones do not work and the noise sound is not muted.
the code:
if frequency != 90.4:
if radioout:
noise.volume_db = 0
snd1.volume_db = -80
if frequency != 93.8:
if radioout:
noise.volume_db = 0
snd2.volume_db = -80
if frequency == 90.4:
if radioout:
noise.volume_db = -80
snd1.volume_db = 0
elif frequency == 93.8:
noise.volume_db = -80
snd2.volume_db = 0
if radioout != true:
noise.volume_db = -80
snd1.volume_db = -80
snd2.volume_db = -80
Let’s follow the logic for 90.4. I’m assuming radioout is true:
if frequency != 90.4:
# This is false since the frequency is indeed 90.4,
# so skip this block and go to the next if.
if frequency != 93.8:
# This is true since the frequency is not 93.8,
# so execute this block. Noise is set to mid-
# volume, and snd2 is off. Go to the next if.
if frequency == 90.4:
# This is true since the frequency is indeed 90.4,
# so execute this block. Noise is set to off and
# snd2 if set to mid-volume. Go to next if.
if radioout != true:
# This is false since radioout is true, so skip this
# block.
The end result is that noise is off and snd2 is set to mid-level. snd1 is left at its prior state. This accounts for the first one working.
For frequency of 93.8:
if frequency != 90.4:
# This is true, so noise is mid-level, snd1 is off.
# Go to next if.
if frequency != 93.8:
# This is false, so skip the block and go to the
# next if.
if frequency == 90.4:
# This is false, so skip the block and go to the
# next if.
if radioout != true:
# This is false since radioout is true, so skip this
# block.
The end result is that noise is mid-level, snd1 is off, and snd2 is left at its prior state. This matches the results you’re seeing.