Assigning sounds to keypresses?
by Eric Rea · in Torque Game Engine · 03/02/2007 (6:35 pm) · 23 replies
Hello, this is my first time posting and i just wanted to start by saying what a wonderful community you have here. i have rescently bought TGE and played some in TGB but i have very little scripting knowledge... with that said i am wondering if there is an easy way to assign custom sounds to keypresses in either tgb or tge?
example: ingame a player can hit any number key from 1-10 and a different custom sound plays.
anyone have any ideas? please keep in mind i am an artist with little to no scriting knowledge!
thanks in advance!
- eric
example: ingame a player can hit any number key from 1-10 and a different custom sound plays.
anyone have any ideas? please keep in mind i am an artist with little to no scriting knowledge!
thanks in advance!
- eric
#2
i applied the changes as you suggested, but didn't achieve any results ingame.. or at least none that i could tell.
i played around with the placement of the cripts you provided and it didn't seem to make a difference. i currently have the 'audioProfiles.cs' scripts at the bottom of the page in the order you provided them and the 'default.bind.cs' script down at the bottom under misc.
i noticed that that script has an unusual bit that the others in this particular file don't, 'for(%i = 0; %i < 9; %i++)' but then again it all looks unusual to me, heh.
i'm not sure where to locate an error log or anything like that, i'm assuming there is one?
not sure what to do next for trouble shooting... any additional help would be much appreciated!
thanka again!!
03/04/2007 (2:31 pm)
Hey zod, thanks so much for your help!i applied the changes as you suggested, but didn't achieve any results ingame.. or at least none that i could tell.
i played around with the placement of the cripts you provided and it didn't seem to make a difference. i currently have the 'audioProfiles.cs' scripts at the bottom of the page in the order you provided them and the 'default.bind.cs' script down at the bottom under misc.
i noticed that that script has an unusual bit that the others in this particular file don't, 'for(%i = 0; %i < 9; %i++)' but then again it all looks unusual to me, heh.
i'm not sure where to locate an error log or anything like that, i'm assuming there is one?
not sure what to do next for trouble shooting... any additional help would be much appreciated!
thanka again!!
#3
Open that file in a text editor and look for and syntax or other erros. That "for(%i = 0; %i < 9; %i++)" is just a loop that saves you from writing out 10 bindCmd calls. It is possible that this line "%profile = nameToId("Key @ %key);" is not functioning properly, none of what I pasted above is tested, just ment as an example.
03/04/2007 (2:54 pm)
Your console log file should be in the same folder as your .exe file. console.logOpen that file in a text editor and look for and syntax or other erros. That "for(%i = 0; %i < 9; %i++)" is just a loop that saves you from writing out 10 bindCmd calls. It is possible that this line "%profile = nameToId("Key @ %key);" is not functioning properly, none of what I pasted above is tested, just ment as an example.
#4
Compiling starter.fps/client/scripts/audioProfiles.cs...
starter.fps/client/scripts/audioProfiles.cs Line: 40 - parse error
>>> Advanced script error report. Line 40.
>>> Some error context, with ## on sides of error halt:
new AudioProfile(AudioButtonOver)
{
filename = "~/data/sound/buttonOver.wav";
description = "AudioGui";
^preload = true;
};
function playKeySound(%key)
{
if ( alxIsPlaying( $KeySound ) )
alxStop( $KeySound );
%profile = nameToId("Key @ %key);
## ## $KeySound = alxPlay( %profile );
}
new AudioProfile(Key1)
{
filename = "~/data/sound/basswah.wav";
description = "AudioGui";
preload = true;
};
new AudioProfile(Key2)
{
filename = "~/data/sound/guitarriff.wav";
description = "AudioGui";
>>> Error report complete.
anyways thanks again.
03/04/2007 (3:09 pm)
Hey! seems like there was an error having to do with one of the scripts but i'm not sure what it means...Compiling starter.fps/client/scripts/audioProfiles.cs...
starter.fps/client/scripts/audioProfiles.cs Line: 40 - parse error
>>> Advanced script error report. Line 40.
>>> Some error context, with ## on sides of error halt:
new AudioProfile(AudioButtonOver)
{
filename = "~/data/sound/buttonOver.wav";
description = "AudioGui";
^preload = true;
};
function playKeySound(%key)
{
if ( alxIsPlaying( $KeySound ) )
alxStop( $KeySound );
%profile = nameToId("Key @ %key);
## ## $KeySound = alxPlay( %profile );
}
new AudioProfile(Key1)
{
filename = "~/data/sound/basswah.wav";
description = "AudioGui";
preload = true;
};
new AudioProfile(Key2)
{
filename = "~/data/sound/guitarriff.wav";
description = "AudioGui";
>>> Error report complete.
anyways thanks again.
#5
- Create a new .cs file named "keyPressAudio.cs" and place the following code inside it:
- Add this line to "starter.fps/client/init.cs":
- Delete your "starter.fps/client/config.cs" file for the new keybindings to take affect.
PS Don't forget to change the paths in the "keyPressAudio.cs" script to lead to your 10 audio files.
03/04/2007 (7:26 pm)
Here's a complete working solution for you Eric. I've included some basic comments to help you understand what's going on. - Create a new .cs file named "keyPressAudio.cs" and place the following code inside it:
//-----------------------------------------------------------------------------
// keyPressAudio.cs (client)
// Play audio sound on keyboard input
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Define our Audio Description.
// This stores the values/properties that our audio sounds will use when played
//-----------------------------------------------------------------------------
new AudioDescription(KeyPressAudio)
{
volume = 1.0;
isLooping = false;
is3D = false;
type = $SimAudioType;
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Now define our 10 Audio Profiles that contain the sound files that will be
// played upon pressing keyboard numbers 0-9
//-----------------------------------------------------------------------------
new AudioProfile(key0)
{
filename = "~/data/sound/sound0.wav"; // Replace this with the path and name
description = "KeyPressAudio"; // of your 10 audio files
preload = true;
};
new AudioProfile(key1)
{
filename = "~/data/sound/sound1.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key2)
{
filename = "~/data/sound/sound2.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key3)
{
filename = "~/data/sound/sound3.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key4)
{
filename = "~/data/sound/sound4.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key5)
{
filename = "~/data/sound/sound5.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key6)
{
filename = "~/data/sound/sound6.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key7)
{
filename = "~/data/sound/sound7.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key8)
{
filename = "~/data/sound/sound8.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key9)
{
filename = "~/data/sound/sound9.wav";
description = "KeyPressAudio";
preload = true;
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// This is the function that will play our corresponding audio file
//-----------------------------------------------------------------------------
function playAudio(%id)
{
alxPlay(key@%id);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Bind keyboard numbers 0-9 to our "playAudio" function
//-----------------------------------------------------------------------------
for (%i = 0; %i <= 9; %i++)
{
moveMap.bindCmd(keyboard, %i, "playAudio(\"" @ %i @ "\", " @ %i @ ");", "");
}
//------------------------------------------------------------------------------ Add this line to "starter.fps/client/init.cs":
exec("./scripts/keyPressAudio.cs");- Delete your "starter.fps/client/config.cs" file for the new keybindings to take affect.
PS Don't forget to change the paths in the "keyPressAudio.cs" script to lead to your 10 audio files.
#6
Activating DirectInput...
keyboard0 input device acquired.
Mapping string: Kork to index: 13
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
*** ENDING MISSION
i'm not sure what i could be doing wrong. i have the same paths as the ones you supplied in the script so i didn't change anything there, and i changed the name of my audio files to match the script. i placed the 'exec' script here:
/// Load client-side Audio Profiles/Descriptions
exec("./scripts/audioProfiles.cs");
exec("./scripts/keyPressAudio.cs");
and i deleted the config before starting.
i greatly appreciate the work you've done so far and would be willing to give you some custom game art or something in return. any more ideas would be most welcome but i understand if you don't have time to continue.
thanks again bud!
~e
03/11/2007 (4:35 pm)
Tim, thanks so much for your help and i apologize for not getting back to you on this sooner but i failed at my first attempt last week and wanted to try again this weekend. for some reason i still can't seem to get it working though... this is the error i get towards the bottom of my console.log right before i log out.Activating DirectInput...
keyboard0 input device acquired.
Mapping string: Kork to index: 13
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
*** ENDING MISSION
i'm not sure what i could be doing wrong. i have the same paths as the ones you supplied in the script so i didn't change anything there, and i changed the name of my audio files to match the script. i placed the 'exec' script here:
/// Load client-side Audio Profiles/Descriptions
exec("./scripts/audioProfiles.cs");
exec("./scripts/keyPressAudio.cs");
and i deleted the config before starting.
i greatly appreciate the work you've done so far and would be willing to give you some custom game art or something in return. any more ideas would be most welcome but i understand if you don't have time to continue.
thanks again bud!
~e
#7
Well, you've done something wrong as if you look at my code there's no "playKeySound" function. I named my function "playAudio". Are you sure you followed my instructions correctly? My code is meant to replace Zod's code.
Looks like your keybindings are not being assigned/updated.
Make sure all scripts are compiling without error, check the console log.
03/11/2007 (4:53 pm)
Quote:
(0): Unable to find functionc
Well, you've done something wrong as if you look at my code there's no "playKeySound" function. I named my function "playAudio". Are you sure you followed my instructions correctly? My code is meant to replace Zod's code.
Looks like your keybindings are not being assigned/updated.
Make sure all scripts are compiling without error, check the console log.
#8
Activating DirectInput...
keyboard0 input device acquired.
Mapping string: Kork to index: 13
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
*** ENDING MISSION
i'm not sure what i could be doing wrong. i have the same paths as the ones you supplied in the script so i didn't change anything there, and i changed the name of my audio files to match the script. i placed the 'exec' script here:
/// Load client-side Audio Profiles/Descriptions
exec("./scripts/audioProfiles.cs");
exec("./scripts/keyPressAudio.cs");
and i deleted the config before starting.
i greatly appreciate the work you've done so far and would be willing to give you some custom game art or something in return. any more ideas would be most welcome but i understand if you don't have time to continue.
thanks again bud!
~e
03/11/2007 (4:53 pm)
Tim, thanks so much for your help and i apologize for not getting back to you on this sooner but i failed at my first attempt last week and wanted to try again this weekend. for some reason i still can't seem to get it working though... this is the error i get towards the bottom of my console.log right before i log out.Activating DirectInput...
keyboard0 input device acquired.
Mapping string: Kork to index: 13
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
(0): Unable to find function playKeySound
*** ENDING MISSION
i'm not sure what i could be doing wrong. i have the same paths as the ones you supplied in the script so i didn't change anything there, and i changed the name of my audio files to match the script. i placed the 'exec' script here:
/// Load client-side Audio Profiles/Descriptions
exec("./scripts/audioProfiles.cs");
exec("./scripts/keyPressAudio.cs");
and i deleted the config before starting.
i greatly appreciate the work you've done so far and would be willing to give you some custom game art or something in return. any more ideas would be most welcome but i understand if you don't have time to continue.
thanks again bud!
~e
#9
for(%i = 0; %i < 9; %i++) moveMap.bindCmd(keyboard, %i, "playKeySound(" @ %i @ ");", "");
placed in the default.bind file..
i took that out, deleted the config file and ran the starterfps game again...
the sound still didn't work and i couldn't find any error messages pertaining to sound or keybinds etc.
the following script showed at the bottom of my console.log :
keyboard0 input device acquired.
03/11/2007 (5:30 pm)
So, i went back into the previous posts and noticed that i didnt take out the previous scripts you gave me.. one of which was :for(%i = 0; %i < 9; %i++) moveMap.bindCmd(keyboard, %i, "playKeySound(" @ %i @ ");", "");
placed in the default.bind file..
i took that out, deleted the config file and ran the starterfps game again...
the sound still didn't work and i couldn't find any error messages pertaining to sound or keybinds etc.
the following script showed at the bottom of my console.log :
keyboard0 input device acquired.
#10
- Triple check that your audio files are named correctly and are in the right path.
- Make sure the "keyPressAudio.cs" script is saved in starter.fps/client/scripts and that it is being executed. After running your game, check to see if a .dso file is being created for that script.
- Modify the "playAudio" function to this:
Once you've done that the two things I need to know from you are:
1) Is a .dso file being created for the "keyPressAudio.cs" script?
2) Do you see a red message in the console saying "play audio function called" after pressing 0-9?
PS are you pressing the 0-9 numbers on the top of the keyboard or are you using the numpad to the right?
03/11/2007 (5:53 pm)
I suggest starting from scratch and following my instructions carefully. I assure you my code works when installed properly, I tested it.- Triple check that your audio files are named correctly and are in the right path.
- Make sure the "keyPressAudio.cs" script is saved in starter.fps/client/scripts and that it is being executed. After running your game, check to see if a .dso file is being created for that script.
- Modify the "playAudio" function to this:
function playAudio(%id)
{
error("play audio function called");
alxPlay(key@%id);
}Once you've done that the two things I need to know from you are:
1) Is a .dso file being created for the "keyPressAudio.cs" script?
2) Do you see a red message in the console saying "play audio function called" after pressing 0-9?
PS are you pressing the 0-9 numbers on the top of the keyboard or are you using the numpad to the right?
#11
- unistalled torque and deleted my torque folder.
- then i went through your intial post of the working solution step-by-step.
- put new .wav files (sound0.wav-sound9.wav) into my data/sound folder
- tested them all in the folder and they played fine
- changed the keyPressAudio paths to it's exact location:
{
filename = "Z:\Torque\SDK\data\sound\sound0.wav";
description = "KeyPressAudio";
preload = true;
};
- also tried changing the path to /data/sound/sound0.wav
- added the 'exec' line to the init file
- there was no config file as i hadn't run my new version of torque yet.
- ran torque fps and still no sound using either the num pad or the number keys up top
- the only errors i had were to do with the crossbow's collision
- a .dso file was created
- there was no red message in the console that made reference to the 'played audio function'
i have no idea what wrong... maybe something about my paths is incorrect? could it be because its stored on my z:/ drive and i launch from my desktop which is on the c:/? (grasping at straws here) do i need any previous torque audio files to go with your script...? anyway, i'm fully stumped!
~e
03/11/2007 (8:37 pm)
Well, I... - unistalled torque and deleted my torque folder.
- then i went through your intial post of the working solution step-by-step.
- put new .wav files (sound0.wav-sound9.wav) into my data/sound folder
- tested them all in the folder and they played fine
- changed the keyPressAudio paths to it's exact location:
{
filename = "Z:\Torque\SDK\data\sound\sound0.wav";
description = "KeyPressAudio";
preload = true;
};
- also tried changing the path to /data/sound/sound0.wav
- added the 'exec' line to the init file
- there was no config file as i hadn't run my new version of torque yet.
- ran torque fps and still no sound using either the num pad or the number keys up top
- the only errors i had were to do with the crossbow's collision
- a .dso file was created
- there was no red message in the console that made reference to the 'played audio function'
i have no idea what wrong... maybe something about my paths is incorrect? could it be because its stored on my z:/ drive and i launch from my desktop which is on the c:/? (grasping at straws here) do i need any previous torque audio files to go with your script...? anyway, i'm fully stumped!
~e
#12
The "~" is not a typo, leave it in. Do NOT include drive letters in your path!
I bet my life your script isn't compiling due to:
Your slashes are around the wrong way. I.e. use a forward slash "/" and not a back slash "\" and you don't need to include your hard drive letter.
Use the numbers at the top and not the keypad numbers.
If you've followed my instructions exactly, you shouldn't even need to change the script, so long as your files are saved in the data/sound folder (according to you they are).
03/11/2007 (8:46 pm)
The pathname should be:filename = "~/data/sound/sound0.wav";
The "~" is not a typo, leave it in. Do NOT include drive letters in your path!
I bet my life your script isn't compiling due to:
filename = "Z:\Torque\SDK\data\sound\sound0.wav";
Your slashes are around the wrong way. I.e. use a forward slash "/" and not a back slash "\" and you don't need to include your hard drive letter.
Use the numbers at the top and not the keypad numbers.
If you've followed my instructions exactly, you shouldn't even need to change the script, so long as your files are saved in the data/sound folder (according to you they are).
#13
- changed the keyPressAudio paths to it's exact location:
Leave the pathnames alone. The "~" tells Torque to start from the mod directory (starter.fps). No need to include drive letters.
03/11/2007 (8:52 pm)
Just to clarify, don't do this step:- changed the keyPressAudio paths to it's exact location:
Leave the pathnames alone. The "~" tells Torque to start from the mod directory (starter.fps). No need to include drive letters.
#14
appreciate your help Tim.
03/14/2007 (7:38 pm)
Well... i tried it with the paths as you said and still no dice. <:/ i can't understand what is wrong.. i am not a coder but even i can see that your steps are quite straight forward and i am following them to the 'T'. if you say they work for you then maybe i am missing something else? i noticed in the init.cs file it says something about an 'openal' driver..? i looked for one but couldn't find any and wasn't sure that had anything to do with anything anyway.. i just purchased tge, could it be that i have a different version than you and that could account for this trouble? can i send you my file to look at or vice versa? appreciate your help Tim.
#15
If you post it here use code blocks.
[ code]
function foo()
{
bar();
}
[ /code]
Minus the spaces.
03/14/2007 (10:05 pm)
Sure, send me the file or post it here. If you post it here use code blocks.
[ code]
function foo()
{
bar();
}
[ /code]
Minus the spaces.
#16
03/17/2007 (10:55 am)
My init.cs file//-----------------------------------------------------------------------------
// Variables used by client scripts & code. The ones marked with (c)
// are accessed from code. Variables preceeded by Pref:: are client
// preferences and stored automatically in the ~/client/prefs.cs file
// in between sessions.
//
// (c) Client::MissionFile Mission file name
// ( ) Client::Password Password for server join
// (?) Pref::Player::CurrentFOV
// (?) Pref::Player::DefaultFov
// ( ) Pref::Input::KeyboardTurnSpeed
// (c) pref::Master[n] List of master servers
// (c) pref::Net::RegionMask
// (c) pref::Client::ServerFavoriteCount
// (c) pref::Client::ServerFavorite[FavoriteCount]
// .. Many more prefs... need to finish this off
// Moves, not finished with this either...
// (c) firstPerson
// $mv*Action...
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function initClient()
{
echo("\n--------- Initializing MOD: FPS Starter Kit: Client ---------");
// Make sure this variable reflects the correct state.
$Server::Dedicated = false;
// Game information used to query the master server
$Client::GameTypeQuery = "FPS Starter Kit";
$Client::MissionTypeQuery = "Any";
//
exec("./ui/customProfiles.cs"); // override the base profiles if necessary
// The common module provides basic client functionality
initBaseClient();
// InitCanvas starts up the graphics system.
// The canvas needs to be constructed before the gui scripts are
// run because many of the controls assume the canvas exists at
// load time.
initCanvas("Torque Game Engine", true);
if (!isObject(Canvas))
// failed, don't make it worse by crashing...
return;
/// Load client-side Audio Profiles/Descriptions
exec("./scripts/audioProfiles.cs");
exec("./scripts/keyPressAudio.cs");
// Load up the Game GUIs
exec("./ui/defaultGameProfiles.cs");
exec("./ui/PlayGui.gui");
exec("./ui/ChatHud.gui");
exec("./ui/playerList.gui");
// Load up the shell GUIs
exec("./ui/mainMenuGui.gui");
exec("./ui/aboutDlg.gui");
exec("./ui/startMissionGui.gui");
exec("./ui/joinServerGui.gui");
exec("./ui/loadingGui.gui");
exec("./ui/endGameGui.gui");
exec("./ui/optionsDlg.gui");
exec("./ui/remapDlg.gui");
exec("./ui/StartupGui.gui");
// Client scripts
exec("./scripts/client.cs");
exec("./scripts/game.cs");
exec("./scripts/missionDownload.cs");
exec("./scripts/serverConnection.cs");
exec("./scripts/playerList.cs");
exec("./scripts/loadingGui.cs");
exec("./scripts/optionsDlg.cs");
exec("./scripts/chatHud.cs");
exec("./scripts/messageHud.cs");
exec("./scripts/playGui.cs");
exec("./scripts/centerPrint.cs");
// Default player key bindings
exec("./scripts/default.bind.cs");
exec("./config.cs");
// Really shouldn't be starting the networking unless we are
// going to connect to a remote server, or host a multi-player
// game.
setNetPort(0);
// Copy saved script prefs into C++ code.
setShadowDetailLevel( $pref::shadows );
setDefaultFov( $pref::Player::defaultFov );
setZoomSpeed( $pref::Player::zoomSpeed );
// Start up the main menu... this is separated out into a
// method for easier mod override.
if ($JoinGameAddress !$= "") {
// If we are instantly connecting to an address, load the
// main menu then attempt the connect.
loadMainMenu();
connect($JoinGameAddress, "", $Pref::Player::Name);
}
else {
// Otherwise go to the splash screen.
Canvas.setCursor("DefaultCursor");
loadStartup();
}
}
//-----------------------------------------------------------------------------
function loadMainMenu()
{
// Startup the client with the Main menu...
Canvas.setContent( MainMenuGui );
// Make sure the audio initialized.
if($Audio::initFailed) {
MessageBoxOK("Audio Initialization Failed",
"The OpenAL audio system failed to initialize. " @
"You can get the most recent OpenAL drivers <a:www.garagegames.com/docs/torque/gstarted/openal.html>here</a>.");
}
Canvas.setCursor("DefaultCursor");
}
#17
03/17/2007 (10:56 am)
My keyPressAudio.cs file //-----------------------------------------------------------------------------
// keyPressAudio.cs (client)
// Play audio sound on keyboard input
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Define our Audio Description.
// This stores the values/properties that our audio sounds will use when played
//-----------------------------------------------------------------------------
new AudioDescription(KeyPressAudio)
{
volume = 1.0;
isLooping = false;
is3D = false;
type = $SimAudioType;
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Now define our 10 Audio Profiles that contain the sound files that will be
// played upon pressing keyboard numbers 0-9
//-----------------------------------------------------------------------------
new AudioProfile(key0)
{
filename = "~/data/sound/sound0.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key1)
{
filename = "~/data/sound/sound1.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key2)
{
filename = "~/data/sound/sound2.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key3)
{
filename = "~/data/sound/sound3.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key4)
{
filename = "~/data/sound/sound4.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key5)
{
filename = "~/data/sound/sound5.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key6)
{
filename = "~/data/sound/sound6.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key7)
{
filename = "~/data/sound/sound7.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key8)
{
filename = "~/data/sound/sound8.wav";
description = "KeyPressAudio";
preload = true;
};
new AudioProfile(key9)
{
filename = "~/data/sound/sound9.wav";
description = "KeyPressAudio";
preload = true;
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// This is the function that will play our corresponding audio file
//-----------------------------------------------------------------------------
function playAudio(%id)
{
error("play audio function called");
alxPlay(key@%id);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Bind keyboard numbers 0-9 to our "playAudio" function
//-----------------------------------------------------------------------------
for (%i = 0; %i <= 9; %i++)
{
moveMap.bindCmd(keyboard, %i, "playAudio(\"" @ %i @ "\", " @ %i @ ");", "");
}
//-----------------------------------------------------------------------------
#18
03/17/2007 (10:57 am)
My audioProfiles.cs//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// Channel assignments (channel 0 is unused in-game).
$GuiAudioType = 1;
$SimAudioType = 2;
$MessageAudioType = 3;
new AudioDescription(AudioGui)
{
volume = 1.0;
isLooping= false;
is3D = false;
type = $GuiAudioType;
};
new AudioDescription(AudioMessage)
{
volume = 1.0;
isLooping= false;
is3D = false;
type = $MessageAudioType;
};
new AudioProfile(AudioButtonOver)
{
filename = "~/data/sound/buttonOver.wav";
description = "AudioGui";
preload = true;
};
#19
03/17/2007 (10:59 am)
And just for good measure, tho not sure you need it, my conifg.cs// Torque Input Map File if (isObject(moveMap)) moveMap.delete(); new ActionMap(moveMap); moveMap.bindCmd(keyboard, "escape", "", "escapeFromGame();"); moveMap.bind(keyboard, "f2", showPlayerList); moveMap.bind(keyboard, "f5", toggleParticleEditor); moveMap.bind(keyboard, "a", moveleft); moveMap.bind(keyboard, "d", moveright); moveMap.bind(keyboard, "w", moveforward); moveMap.bind(keyboard, "s", movebackward); moveMap.bind(keyboard, "space", jump); moveMap.bind(keyboard, "r", setZoomFOV); moveMap.bind(keyboard, "e", toggleZoom); moveMap.bind(keyboard, "z", toggleFreeLook); moveMap.bind(keyboard, "tab", toggleFirstPerson); moveMap.bind(keyboard, "alt c", toggleCamera); moveMap.bindCmd(keyboard, "ctrl w", "commandToServer(\'playCel\',\"wave\");", ""); moveMap.bindCmd(keyboard, "ctrl s", "commandToServer(\'playCel\',\"salute\");", ""); moveMap.bindCmd(keyboard, "ctrl k", "commandToServer(\'suicide\');", ""); moveMap.bindCmd(keyboard, "h", "commandToServer(\'use\',\"HealthKit\");", ""); moveMap.bindCmd(keyboard, "1", "commandToServer(\'use\',\"Crossbow\");", ""); moveMap.bind(keyboard, "u", toggleMessageHud); moveMap.bind(keyboard, "pageup", pageMessageHudUp); moveMap.bind(keyboard, "pagedown", pageMessageHudDown); moveMap.bind(keyboard, "p", resizeMessageHud); moveMap.bind(keyboard, "f3", startRecordingDemo); moveMap.bind(keyboard, "f4", stopRecordingDemo); moveMap.bind(keyboard, "f8", dropCameraAtPlayer); moveMap.bind(keyboard, "f7", dropPlayerAtCamera); moveMap.bind(keyboard, "ctrl o", bringUpOptions); moveMap.bindCmd(keyboard, "n", "NetGraph::toggleNetGraph();", ""); moveMap.bind(mouse0, "xaxis", yaw); moveMap.bind(mouse0, "yaxis", pitch); moveMap.bind(mouse0, "button0", mouseFire);
#20
does anything jump out at you in these other files?]
(fyi my sound files 0-9 are in my starter.fps/data/sound folder)
03/17/2007 (11:03 am)
I can post my console.log as well if you like. its rather large though so just let me know...does anything jump out at you in these other files?]
(fyi my sound files 0-9 are in my starter.fps/data/sound folder)
Zod
You are going to have to do three things.
#1 Create audio profile datablocks for each audio file to be played. These will be put in yje file "starter.fps\client\scripts\audioProfiles.cs".
Example:
new AudioProfile(Key1) { filename = "~/data/sound/buttonOver.wav"; description = "AudioGui"; preload = true; };#2 You are going to have to write a function that will handle the playing of your newly created profiles. I would place this function also in "starter.fps\client\scripts\audioProfiles.cs".
Example:
function playKeySound(%key) { if ( alxIsPlaying( $KeySound ) ) alxStop( $KeySound ); %profile = nameToId("Key @ %key); $KeySound = alxPlay( %profile ); }#3 You are going to have to setup the keybinds for the number keys that will call the function you created. This would be placed somewhere in "starter.fps\client\scripts\default.bind.cs". You will need to make sure no other keybinds are using those keys as they will not be remapable.
Example:
for(%i = 0; %i < 9; %i++) moveMap.bindCmd(keyboard, %i, "playKeySound(" @ %i @ ");", "");