Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Yuri Patrick on Tue 18/09/2012 16:55:35

Title: My poor little mind...
Post by: Yuri Patrick on Tue 18/09/2012 16:55:35
My mind seems to have recently turned to mush. ;)

I'm working away on my game and I remember that I wanted a audio display on the statusbar that says what the volume is set to, muted, 1-100, etc. Now, I can't remember how to get the current value of the volume out of AGS. :(

Can someone point me in the right direction, please? :)

Thanks.
Title: Re: My poor little mind...
Post by: Crimson Wizard on Tue 18/09/2012 17:18:44
Depends on AGS version.
In AGS 3.2 it is System.Volume for master setting and AudioChannel.Volume for each of existing audio channels.
Title: Re: My poor little mind...
Post by: Yuri Patrick on Tue 18/09/2012 18:10:16
Grrumpf! Like I said, brain death. I have a label on the status bar, lblVolume. When I try to get it to display the current volume, I get an error stating that I cannot convert an integer to a string. That's not what I'm trying to do. I'm trying to display the integer, for now.

Here's my code:
Code (AGS) Select
lblVolume.Text = System.Volume;


And AGS' response to that line of code:
GlobalScript.asc(76): Error (line 76): Type mismatch: cannot convert 'int' to 'String*'

Hrm! Would a switching function work? If volume is 0, then it is muted, anything else means that it is on? But then, how do I get the current value of System.Volume into my label?

I just want to display OFF or the current volume level.
Title: Re: My poor little mind...
Post by: Crimson Wizard on Tue 18/09/2012 18:32:31
You cannot cast integer value (System.Volume) to string (lblVolume.Text) like that.
Printing numbers into string is done by the use of Format function.
You should definitely check manual for that, but here's quick example:

Code (ags) Select

lblVolume.Text = String.Format("%d", System.Volume);


EDIT:
With "off":
Code (ags) Select

if (System.Volume > 0)
{
   lblVolume.Text = String.Format("%d", System.Volume);
}
else
{
   lblVolume.Text = "OFF";
}
Title: Re: My poor little mind...
Post by: Yuri Patrick on Tue 18/09/2012 20:16:13
Thank you sooo much, Crimson. I feel kinda silly. The if section was the easy part for me. However, the idea of a string.format was what was blowing my mind.

I know that everything is in the manual, but finding it either by search or by reading is difficult for me. :(

Thanks for the help again, Crimson. :)

BTW: I had some flags to animate in the background and was able to do that on my own. ;)