Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: R4L on Thu 24/08/2006 08:17:02

Title: Setting music volume through buttons? (SOLVED)
Post by: R4L on Thu 24/08/2006 08:17:02
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?
Title: Re: Setting music volume through buttons?
Post by: SSH on Thu 24/08/2006 09:22:53
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.
Title: Re: Setting music volume through buttons?
Post by: R4L on Thu 24/08/2006 09:48:17
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.
Title: Re: Setting music volume through buttons?
Post by: SSH on Thu 24/08/2006 10:22:04
You need to update sldVolume.Value, too
Title: Re: Setting music volume through buttons?
Post by: R4L on Thu 24/08/2006 10:58:20
What do you mean?
Title: Re: Setting music volume through buttons?
Post by: Gilbert on Thu 24/08/2006 11:21:13
Something like this:

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]
Title: Re: Setting music volume through buttons?
Post by: Joe on Thu 24/08/2006 11:22:23
Why dont you use a Slider?
Title: Re: Setting music volume through buttons?
Post by: R4L on Thu 24/08/2006 11:24:45
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.
Title: Re: Setting music volume through buttons?
Post by: Joe on Thu 24/08/2006 11:29:13
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.