Setting music volume through buttons? (SOLVED)

Started by R4L, Thu 24/08/2006 08:17:02

Previous topic - Next topic

R4L

Ok I have a GUI with two arrows, an up arrow, and a down arrow. When the player clicks on the up arrow, the music gets loud by one, and the down arrow turns the music down by one. I tried to use an int to do this:

int music = SetMusicMasterVolume(); //then
if (button==2){
music++;
}

but of course that doesn't work.  Is there a different way to do this?

SSH

Does SetMusicMaster volume return the current value? I don't know.

Anyway, you'd need to set the new volume after you increment music to get that to work.
12

R4L

I don't think I quite get what your saying SSH. I also should mention that I meant SetMusicVolume. I just tried a new way to do it, and I can only raise the volume with the up arrow. I made GUI VOLUME, then made a slider called sldVolume. In my GUI Script I have:

if (interface == STATUSLINE){
  if (button == 0){
    mouse.Mode= eModeLookat;
  }
  if (button == 1){
    mouse.Mode = eModeInteract;
  }
  if (button == 2){
     if (sldVolume.Value == 6){
      return;
      }
   SetMusicVolume(sldVolume.Value+1);
}
  if (button == 3){
    if (sldVolume.Value == 0){
      return;
      }
    SetMusicVolume(sldVolume.Value-1);
}
}

Button 2 is the up arrow and button 3 is the down arrow. I don't know why it doesn't work, as I am pretty sure that it would.

SSH

You need to update sldVolume.Value, too
12


Gilbert

Something like this:
Code: ags

if (interface == STATUSLINE){
Ã,  if (button == 0){
Ã,  Ã,  mouse.Mode= eModeLookat;
Ã,  }
Ã,  if (button == 1){
Ã,  Ã,  mouse.Mode = eModeInteract;
Ã,  }
Ã,  if (button == 2){
Ã,  Ã,  Ã, if (sldVolume.Value == 6){
Ã,  Ã,  Ã,  return;
Ã,  Ã,  Ã,  }
Ã,  Ã, SetMusicVolume(sldVolume.Value+1);
   sldVolume.Value++;
}
Ã,  if (button == 3){
Ã,  Ã,  if (sldVolume.Value == 0){
Ã,  Ã,  Ã,  return;
Ã,  Ã,  Ã,  }
Ã,  Ã,  SetMusicVolume(sldVolume.Value-1);
   sldVolume.Value--;
}
}

[quote][/quote]

Joe

Copinstar © Oficial Site

R4L

#7
Oh I see now Gilbot. Joe Carl, I secretly use a slider, but it isn't shown on the screen. SetMusicVolume is controlled by this slider and the buttons just tell the slider to move up one, or down one, which controls the volume.

Edit:

Gilbot: That worked! Thanks alot!

Joe Carl: Thats what the if (sldVolume.Value == 100){ and if (sldVolume.Value == 0){ are for. It checks to see if the slider is at that value, then returns a return; command to stop the slider from being moved.

Joe

Thats fine, but you have to set the limits, because if you click the turn music up button and the Slider is at the top it will give you an error.
Copinstar © Oficial Site

SMF spam blocked by CleanTalk