Community

 
Post Reply
Quick Reply
Cancel
SR2 Function Reference Builder
3 years ago  ::  Jul 16, 2010 - 9:28PM #1
xhva
Posts: 14
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/reference



You'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.



      
0 (0 Ratings)
Quick Reply
Cancel
3 years ago  ::  Jul 12, 2010 - 11:23PM #2
IdolNinja
Posts: 1,456
Taking a look through the output hosted on your site, and it's a very cool resource. :)



FYI there are 3 core lua files:

system_lib.lua

ug_lib.lua

vint_lib.lua



Also, there is a global missions lua that individual mission scripts can call functions from too:

mission_globals.lua



There may be more, but these are the ones that I definitely know about.
0 (0 Ratings)
Quick Reply
Cancel
3 years ago  ::  Jul 13, 2010 - 3:28AM #3
xhva
Posts: 14
Thanks IdolNinja -- I've updated the links with v1.1 that includes a file override list for Luas that are always loaded. Functions defined in those files are always treated as global. I threw mission_globals.lua in as well as the other three.
0 (0 Ratings)
Quick Reply
Cancel
3 years ago  ::  Jul 15, 2010 - 1:40PM #4
Rooter
Posts: 26
it's not working on for me.
0 (0 Ratings)
Quick Reply
Cancel
3 years ago  ::  Jul 15, 2010 - 6:16PM #5
xhva
Posts: 14
Do you mean the website or the downloadable program? If the program, I'll need a bit of info to reproduce your issue:


  1. What operating system are you using? Is it 32/64bit?

  2. Which directory are you running the program from?

  3. What messages does the program give you? You may need to run it from the command-line to see them. If you can copy/paste the output, that'd be great.

  4. Does the "sr2_function_reference" folder get created? Are there 46 files and 1 folder in it, or less than that?



0 (0 Ratings)
Quick Reply
Cancel
3 years ago  ::  Jul 16, 2010 - 6:09AM #6
Rooter
Posts: 26

The downloadable program.

1.Im using Windows XP 36 bit.

2.Im running the program from /modding/extracted/patch.

3.It doesn't give me any message, it opens the command-line, but it closes it after less then a second from when it opened it.

4.The "sr2_function_reference" folder doesn't get create and thats my problem.

0 (0 Ratings)
Quick Reply
Cancel
3 years ago  ::  Jul 16, 2010 - 6:36PM #7
xhva
Posts: 14
Version 1.2 of the builder has been uploaded to:



   xhva.net/sr2/saints_row_2_function_refer...



I've also updated the copy of the generated HTML files (only minor text changes though):



   xhva.net/sr2/reference_v1.2/





Rooter, give this version a go -- I fixed a few silly things including the likely cause of the 'instant close' bug. Thanks for your bug report!





Aside: can any forum regulars tell me why I can't edit the original message again? Annoying that I can't update the links :(
0 (0 Ratings)
Quick Reply
Cancel
3 years ago  ::  Jul 16, 2010 - 7:59PM #8
foamcup
Posts: 248
The edit button is above the first post.
0 (0 Ratings)
Quick Reply
Cancel
3 years ago  ::  Jul 16, 2010 - 8:11PM #9
xhva
Posts: 14
Gawd, me so dumb. Thanks :)
0 (0 Ratings)
Quick Reply
Cancel
Post Reply
Quick Reply
Cancel
Jump Menu:
    Viewing this thread :: 0 registered and 1 guest
    No registered users viewing