Game Development Community

Chaptor20 intro music

by James W. · in Torque Game Engine · 02/14/2007 (9:00 pm) · 5 replies

This error came up in my log I can't get the intro music to play

control/client/initialize.cs (70): Unable to find function PlayMusic

this is my script in InitializeClient.cs (clip)

InitBaseClient(); // basic client features defined in the common modules

// Make sure a canvas has been built before any interface definitions are
// loaded because most controls depend on the canvas to already exist when
// they are loaded.

InitCanvas("Emaga6 - 3D2E Sample Game");///***KCF***-21-SEP-2006

PlayMusic(AudioIntroMusicProfile);

this is my script in sndprofile.cs (clip)

new AudioDescription(AudioMusic)
{
volume = 0.8;
isLooping = false;
is3D = false;
type = $MusicAudioType;
};

new AudioProfile(AudioIntroMusicProfile)
{
filename = "~/data/sound/twlogo.wav";
description = "AudioMusic";
preload = true;
};

function PlayMusic(%handle)
{
if (!alxIsPlaying(%handle))
alxPlay(%handle);
}

I can't figure out what is wrong in the function
I even did a channel assignment for $MusicAudioType hopeing it would fix it

any ideas

#1
02/14/2007 (9:26 pm)
Your missing one of these ; in your PlayMusic function. That would be creating a syntax error and your script wouldn't be loading.

You should learn how to use the console, it is your friend and makes diagnosing simple problems like this quick & easy.

Here's how your function should look:
function PlayMusic(%handle)
{
   if (!alxIsPlaying(%handle));
      alxPlay(%handle);
}
#2
02/15/2007 (6:30 am)
I added the ; in the PlayMusic function and I get this error

control/client/misc/sndprofile.cs Line: 18 - Syntax error.

console still reports

control/client/initialize.cs (70): Unable to find function PlayMusic
#3
02/15/2007 (9:32 am)
Make sure sndprofile.cs is loaded before you call PlayMusic. If it isn't try doing something like
exec("control/client/misc/sndprofile.cs");
before calling PlayMusic.
#4
02/15/2007 (11:01 am)
Well I tried

InitCanvas("Emaga6 - 3D2E Sample Game");///***KCF***-21-SEP-2006
exec("./control/client/misc/sndprofile.cs");
PlayMusic(AudioIntroMusicProfile);

still get the message
control/client/initialize.cs (71): Unable to find function PlayMusic

I also tried to use the server with this change and it crashed.

I did put the this directly in control/client/initialize.cs

new AudioDescription(AudioMusic)
{
volume = 0.8;
isLooping = false;
is3D = false;
type = $MusicAudioType;
};

new AudioProfile(AudioIntroMusicProfile)
{
filename = "~/data/sound/twlogo.wav";
description = "AudioMusic";
preload = true;
};

function PlayMusic(%handle)
{
if (!alxIsPlaying(%handle))
alxPlay(%handle);
}

The music did play when used the client only, but when I used the server it crashed everytime.
So I change it back like the book said.
I just want to finnish the book so I can then move on to the game programmer's guide to torque.

thanks for all the help
#5
05/16/2007 (3:32 pm)
Try placing the function inside initialize.cs, maybe at the beginning of the file. That way, it is a complete gaurantee that it sees the function before PlayMusic() is called. Hope that works for you.

Also, if that doesn't do it, delete the compiled initialize.cs.dso. That sometimes causes problems when you make code changes to problematic script.