Loading Audio File by Exact Name without using "bind"?
Forum rules
Read this before posting in this section
Read this before posting in this section
Loading Audio File by Exact Name without using "bind"?
Is there a way to load an audio file by its exact name without having "bind" in the command? I'm trying to make a little menu for fast audio switching but lua blocks the command "bind". It also blocks "alias" so that won't work either =P..
Re: Loading Audio File by Exact Name without using "bind"?
Do you mean "bind" is a reserved word in lua? Most scripting languages will have a way for you to use reserved words (i.e. enclosed in "string literals"). Other than that, anyway you can get the Command Relay Key bound to the command you want will work (although I can think of any other than using the bind syntax or the index number, but that's not exact)
If you give me more insight on what you're trying to achieve, I can make a better suggestion. Is this lua scripting for the source engine?
edit: bingo, I was pretty close: http://www.lua.org/pil/11.5.html
If you give me more insight on what you're trying to achieve, I can make a better suggestion. Is this lua scripting for the source engine?
edit: bingo, I was pretty close: http://www.lua.org/pil/11.5.html
Re: Loading Audio File by Exact Name without using "bind"?
I am Lua coding for Garry's Mod. The commands alone work fine when I type them manually or bind them to a key. It's Lua blocking the commands with "bind" in them so when I try to run the command to switch the song, it will say that the command "bind" is blocked.
When I press the button, it does this: audioclipname is the song selected in the derma list (no bugs in it it works fine)
If I press the button with the clip "Music-DaftPunk-Discovery_01_OneMoreTime" selected, it runs the command in console
However, it blocks the command "bind" when it's used through Lua so it will not let me switch songs, therefore ruining all my efforts and wasting a good few hours of my life. >.<
EDIT: RunConsoleCommand does the same thing.
Runs the console command:
Resulting in this error being printed to console:
When I press the button, it does this:
Code: Select all
LocalPlayer():ConCommand( "bind = " .. audioclipname .. "; hldjsf" )
If I press the button with the clip "Music-DaftPunk-Discovery_01_OneMoreTime" selected, it runs the command in console
Code: Select all
bind = Music-DaftPunk-Discovery_01_OneMoreTime; hldjsf
However, it blocks the command "bind" when it's used through Lua so it will not let me switch songs, therefore ruining all my efforts and wasting a good few hours of my life. >.<
Code: Select all
ConCommand blocked! (bind = Music-DaftPunk-Discovery_01_OneMoreTime; hldjsf)
EDIT: RunConsoleCommand does the same thing.
Code: Select all
RunConsoleCommand( "bind", "=", "" .. audioclipname, ";", "hldjsf" )
Runs the console command:
Code: Select all
bind = Music-DaftPunk-Discovery_01_OneMoreTime; hldjsf
Resulting in this error being printed to console:
Code: Select all
RunConsoleCommand: Command is blocked! (bind)
Re: Loading Audio File by Exact Name without using "bind"?
Hmm, seems like a limitation (possibly deliberate) by the Gmod devs. There's probably a reason or workaround for it they may know of. If not, there may be other ways to bind the key, BindToggle may work.
Re: Loading Audio File by Exact Name without using "bind"?
http://wiki.garrysmod.com/?title=G.RunConsoleCommand
Scroll to the bottom of that and it has all the console commands that are blocked.
BindToggle is blocked as well.. Is it possible for you to make a custom console command for loading files instead of "bind ="?
Scroll to the bottom of that and it has all the console commands that are blocked.
BindToggle is blocked as well.. Is it possible for you to make a custom console command for loading files instead of "bind ="?
Re: Loading Audio File by Exact Name without using "bind"?
Not without significantly changing HLDJ's infrastructure. Why not just create a bunch of aliases and call them in the script:
Code: Select all
alias loadmyfile1 "bind = >$\music\my*audio*file; hldjsf"
...
Code: Select all
LocalPlayer():ConCommand( loadmyfile1 )
Re: Loading Audio File by Exact Name without using "bind"?
I would do that but you would have to recreate the aliases every time you launch Garry's Mod or put them in cfg but I don't know how to do the 2nd option. So I would have to type like 150 commands every time I use HLDJ. (Alias is also blocked in Lua so I can't have an autorun Lua that runs all of them on startup)
Re: Loading Audio File by Exact Name without using "bind"?
Game scripting is much easier than Lua scripting, read (step #2): http://www.hldj.org/forums/viewtopic.php?f=6&t=252
just place all the aliases in your hldj_custom.cfg.
If you want to get fancy, you can even use Lua or some other scripting language (Perl, etc) to go through all your audio files and generate the aliases dynamically.
just place all the aliases in your hldj_custom.cfg.
If you want to get fancy, you can even use Lua or some other scripting language (Perl, etc) to go through all your audio files and generate the aliases dynamically.
Re: Loading Audio File by Exact Name without using "bind"?
I just want to be 100% clear so I can make this work right XD.. If I have a song named "OneMoreTime" and I wanted to create an alias command to load that song when I type "OneMoreTime" in console, what would be the alias command? =P
Re: Loading Audio File by Exact Name without using "bind"?
There are a few different ways listed in the link, but here's the two I would recommend:
relative to your Audio Folder:
absolute path:(where X:\ is the drive or network address)
Keep in mind you can change your Command Relay Key from the default ("=") to anything.
Also, if the path contains spaces, you can do one of two things:
1) replace all spaces in the path with "*"
2) create an extra alias
Either method should work fine. The first can be a bit tedious at times (although it's much easier if you make a script to replace all spaces with "*"); the second requires more aliases and I'm not sure if it works in all games. See which one you prefer.
relative to your Audio Folder:
Code: Select all
alias load_onemoretime "bind = >$\OneMoreTime; hldjsf"
Code: Select all
alias load_onemoretime "bind = >X:\path\to\audio\folder\OneMoreTime; hldjsf"
Keep in mind you can change your Command Relay Key from the default ("=") to anything.
Also, if the path contains spaces, you can do one of two things:
1) replace all spaces in the path with "*"
Code: Select all
alias load_onemoretime "bind = >$\this*folder*has*spaces\OneMoreTime; hldjsf"
Code: Select all
alias loada_onemoretime bind = ">$\this folder has spaces\OneMoreTime"
alias loadb_onemoretime "loada_onemoretime; hldjsf"
Re: Loading Audio File by Exact Name without using "bind"?
I have all the sounds in my audio folder renamed for there to be no spaces in it. Thanks for all the help! =D
Re: Loading Audio File by Exact Name without using "bind"?
glad you got it working