Game Development Community

How To Set Audioprofile From ConsoleMethod?

by Liu Yi · in Torque Game Engine · 06/07/2007 (8:25 pm) · 0 replies

Hi all,

I set my buttons so that when I hover the mouse pointer over the buttons, a sound is played.

In guiButtonBaseControl.cc I added the line:

addField("soundButtonOver", TypeAudioProfilePtr, Offset(mSoundButtonOver, GuiButtonBaseCtrl));

in function

void GuiButtonBaseCtrl::initPersistFields()

That way, I can set AudioProfile for my buttons in the script.

I also want to add a ConsoleMethod so that I can change the AudioProfile for the button in the middle of the game. So, I add a new function in guiButtonBaseControl.cc

void GuiButtonBaseCtrl::setMOverSnd(AudioProfile newSndProfile) {
mSoundButtonOver = newSndProfile;
}

Now, I need make a ConsoleMethod to call this function from script. This is the ConsoleMethod:

ConsoleMethod( GuiButtonBaseCtrl, setMOverSnd, void, 3, 3, "Set new audio profile" ) {
object->setMOverSnd( argv[2] );
}

This ConsoleMethod doesn't work because the argument passed is of String type. I need to convert the argument to AudioProfile type.

I'm not familiar with C programming. Anyone can help me?

Thanks a lot.