Writing CFG Mods Tutorial 7 - Advanced Escaping With Backslash

Advanced Escaping

 

I'm not going to lie; this is going to get confusing. It took a while in the PC version of the game's console to figure out, and I'm still not entirely sure how this works.

 

Remember we did the control sets with vstr? Let's do it again, but this time with different controls. With the first controls, we want the right shoulder to toggle noclip AND notarget and we want the left shoulder to toggle godmode AND player_sustainammo. For the second controls, we want the right shoulder to toggle g_speed and the left shoulder to toggle g_gravity. Using the vstr method, we would have:

 

bind button_rshldr "vstr rb"
bind button_lshldr "vstr lb"
bind button_back "vstr toggle_controls"
set rb "noclip"
set lb "god"
set toggle_controls "vstr controls_1"
set controls_1 "set rb \"noclip;notarget\";set lb \"god;toggle player_sustainammo\";set toggle_controls vstr controls_2"

set controls_2 "set rb toggle g_speed 300 400 700;set lb toggle g_gravity 10 100 800;set toggle_controls vstr controls_1"

 

As messy and complicated as that looks, it wouldn't even work. For example, when it executes the 7th line where it says

set controls_1 "set rb \"noclip;notarget\";set lb \"god;toggle player_sustainammo\";set toggle_controls vstr controls_2"

 

The game will see the semicolon as the end of the set command, the first set command. The game will see the first command as

 

set controls_1 "set rb \"noclip

 

Remember how I said that the semicolons separate commands? Well, for some reason those semicolons ended the first command, even though we were in escaped quotes AND regular quotes. I'm sure there is some sort of cancelling-out effect here, but regardless of the reason, here is the solution:

 

bind button_rshldr "vstr rb"
bind button_lshldr "vstr lb"
bind button_back "vstr toggle_controls"
set rb "noclip"
set lb "god"
set toggle_controls "vstr controls_1"
set controls_1 "set rb \"" noclip;notarget "\";set lb \"" god;toggle player_sustainammo "\";set toggle_controls vstr controls_2"

set controls_2 "set rb toggle g_speed 300 400 700;set lb toggle g_gravity 10 100 800;set toggle_controls vstr controls_1"

 

 

Don't start tearing your hair out here if you can't see what I changed. All I changed was the 7th line, which is now:

 

set controls_1 "set rb \"" noclip;notarget "\";set lb \"" god;toggle player_sustainammo "\";set toggle_controls vstr controls_2"

 

Instead of a backslash and quote, we now have a backslash, quote, and ANOTHER quote. That's right, we have quotes inside of escaped quotes inside of quotes. Let's keep Cobb away from this one, we've gone deep enough. Also note that I've put spaces before and after the "quote sandwiches" . This hasn't been necessary before, but it seems we've entered the twilight zone here. The code above WILL work, just don't ask how.

 

This tutorial may seem like a bit of a let-down, but the use the "quote sandwiches" is actually very helpful. I'm passed the point of losing sleep over this, but if I can come up with a logical reason for this, I'll be sure to update it. That being said, if you can come up with something, be sure to email me and we can discuss it.

 

 

You've successfully(?) completed all the tutorials on writing your own CFG mods. If you have any ideas for more tutorials, I'm always open to suggestions.

 

Click here to go back to the tutorials page.

 

Or, click here to go to the entertainment section.