Saints Row 2 uses a programming language called Lua to describe how some parts of the game work, including missions, strongholds, clothing stores and vehicle customisation. Lua files are where gameplay decisions are made (eg. is Gat dead? Has Jessica turned off the alarm? Have all the leutenants been killed?) and actions are taken in response (eg. completing/failing a mission, adding a piece of clothing to your wardrobe, unlocking a map area).
The SR2 developers wrote a library of programming functions that can be used in making decisions or taking actions, for example "character_is_in_vehicle()" tells us whether a character is on a vehicle and "audio_play()" plays an audio sample. Hundreds of functions exist that tell us the state of the game and give ways to affect it.
The Function Reference Builder is a small program that creates a reference for all these functions and makes it easier to see how they're used. You can either view the reference online or build your own version from your extracted patch directory. Please be aware though that this tool will not do any programming for you and will not teach you how to use Lua. There's many guides out there that teach Lua programming.
Viewing the reference online
Head off to: xhva.net/sr2/referenceYou'll be presented with a long, long list of functions. Click on one to see a more detailed view including the function definition and every example from the Lua files. Click the definition or example to see it inside the original file (useful to get an idea of context).
Functions are broken down into globals (always available) and locals (available only in the same script, or by including the file inside another script).
Creating your own version to use at home
Download: xhva.net/sr2/saints_row_2_function_refer...Inside the zip is an .exe file. Extract it into your moddingextractedpatch directory and double-click it. A command-line box will appear, process every Lua in there, then create a folder full of HTML files. Tada, your reference has been built. You're free to move the new folder wherever you like.
Once you've run the program once, a config file is created with some additional options such as file names and which Lua files are considered 'always loaded'.
Improvements and the source code
Feedback is welcome, as are improvements to overall format, the style sheets, the source code, etc. Credit for any improvements is assured.
I've included the source code to the builder for anyone who wants to play, extend, rip apart.. It's written in PHP, so you'll need some extra files to run it on the command line. Instructions are in src/readme.txt. Make sure to read the very liberal licence at the top of the code.