[Solved] Convert audiochannel number to int

Started by Georgeqgreg, Fri 12/07/2013 02:46:27

Previous topic - Next topic

Georgeqgreg

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
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! ;)

monkey0506

As you discovered, the Play function returns an AudioChannel* which should be used like so:

Code: ags
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
if (radiochannel.ID == n) do_something();

Georgeqgreg

Things to keep in mind, yes, I indeed am fine! My function works nicely now!

SMF spam blocked by CleanTalk