Page 1 of 1
Using L4D radials to play audio
Posted: Fri Mar 20, 2009 10:17 am
by mouseandcat
So, I thought it would be neat to set up a radial menu in L4D that one could use to play sound bytes during a game with HLDJ. Going off of a radial menu tutorial (
http://www.fpsbanana.com/tuts/7509), I came up with this formula:
Code: Select all
"Center"
{
"command" "bind = [filename]; hldjsf; playaudio"
"text" "[audio title]"
}
I attempted to combine the code for binding songs to keys with the code for setting up radial menus. Unfortunately, this did not work, as it apparently had issues with recognizing the structure of the bind command with a file rather than a command. Instead, it plays whatever file was already set up in HLDJ.
If anyone can think of a way that this can be done, or if anyone knows that this cannot be done, please let me know.
[Note: moved to Tips & Tricks]
Re: Using L4D radials to play audio
Posted: Fri Mar 20, 2009 4:56 pm
by Renegade
Interesting concept. The syntax seems to be similar to HL1's command menu (
http://www.hldj.org/forums/viewtopic.php?f=6&t=147).
Does the game specifically complain about your bind syntax? If so, remember that
it cannot contain any spaces. As explained in the binding tutorial, HLDJ provides a workaround for this by allowing you to substitute spaces with the "*" character:
"bind = >$\this*path\had*spaces\in*it.wav; hldjsf; wait 80; playaudio"
Since it takes a moment to actually copy the wav file, you should introduce a delay between selecting and playing the file, as above. You can play around with this duration by adjusting the number (In pre-SDK2007 games you can use HLDJ's built-in wait command, "halfsec" (which will be deprecated and replaced by "hldj_wait" in future versions), but this will not work for L4D).
Re: Using L4D radials to play audio
Posted: Fri Mar 20, 2009 7:22 pm
by mouseandcat
That might explain it. After some tinkering, I threw in some "halfsec" commands in, but that didn't seem to make a difference - and that would be why. As for the bind syntax, I compensated for the spaces (or just avoided them altogether), but when I looked in the console after issuing the radial command, I saw that it had responded with something like "bind [key] <command>", possibly suggesting that I had used improper syntax.
Another option, though it would have to be adjusted every time music is added, might be to have it execute the necessary commands to load a song manually (as in, for the first song in the main directory, "la; 3" or something along those lines).
Thanks for your help. I'll try it again and see if I can get it to work.
Re: Using L4D radials to play audio
Posted: Fri Mar 20, 2009 9:41 pm
by Renegade
Admittedly, attempting it for the first time was a bit tedious since the game required restarting before any changes to the menus took effect, but aside from that, everything worked as expected. Again, make sure you haven't got any spaces or other weird characters in your path.
For reference, here's the script I just setup for some quick testing:
Code: Select all
...
//--------------------------------------------------------------
"HLDJ,Survivor,Alive"
{
"Center"
{
"command" "bind = >$\epic*&*l4d\RTCW*-*Assault.wav; hldjsf; wait 80; playaudio"
"text" "RTCW"
}
"North"
{
"command" "bind = >$\epic*&*l4d\Michael*Jackson*-*Thriller.wav; hldjsf; wait 80; playaudio"
"text" "Thriller"
}
"South"
{
"command" "playaudio_off"
"text" "Stop Playback"
}
"East"
{
"command" "bind = >$\epic*&*l4d\Franz*Schubert*-*Maria*Callas*-*Ave*Maria.wav; hldjsf; wait 80; playaudio"
"text" "Ave Maria"
}
"West"
{
"command" "bind = >$\epic*&*l4d\Beethoven*-*String*Quartet*in*C-Sharp*Minor.wav; hldjsf; wait 80; playaudio"
"text" "String Quartet"
}
}
...
Also, if you don't want to make too much of a mess in this file, you can always simplify the binds into a single alias which you can define elsewhere. I.E. for each radial menu option, use aliases like "load_song_X" or "my_radial_north" and then define this to load whatever song you want in your hldj_custom.cfg file.