Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Georgeqgreg on Fri 12/07/2013 02:46:27

Title: [Solved] Convert audiochannel number to int
Post by: Georgeqgreg on Fri 12/07/2013 02:46:27
I'm want to store the channel number of a playing audio clip as a variable, and I did indeed work out how to read the channel, with this command.

Code (AGS) Select
radiochannel = aradio1.Play();

But on compile, I get this message.

radiocontrol.asc(8): Error (line 8): Type mismatch: cannot convert 'AudioChannel*' to 'int'

I thought audio channel was supposed to be returned as an int. What gives?

(Yes this question is pretty dumb. Oh well.)

EDIT: Doh. It seems Audiochannel* is a valid type for a variable. I should think things through more often. I'll see if this fixed my problem and edit the thread one last time.

EDIT 2: And everything works as I wanted it! I shouldn't give up and look for a walkthrough so easily! ;)
Title: Re: Convert audiochannel number to int
Post by: monkey0506 on Fri 12/07/2013 03:09:52
As you discovered, the Play function returns an AudioChannel* which should be used like so:

Code (ags) Select
AudioChannel *radiochannel = aradio1.Play();

If for some weird reason you need the integer ID of the channel, that's available through the ID property:

Code (ags) Select
if (radiochannel.ID == n) do_something();
Title: Re: Convert audiochannel number to int
Post by: Georgeqgreg on Fri 12/07/2013 03:11:58
Things to keep in mind, yes, I indeed am fine! My function works nicely now!