Most of the things modders are usually interested in modifying are in Patron accessible through database tables and definition files, but there are some things done in the vanilla game via scripting.
Script assembly language
That's the name of the language used in Patron: Script Assembly Language, hence the extension .sal . Sal files are interpreted on-the-fly, and unless we ever start compressing them for faster execution, they'll be interpreted on execution. This means, the file is read, interpreted and executed when it is called. Quite useful for far prototyping and testing.
The file is executed line-by-line. If an error is encountered, you can count on an error to appear in PatronLog.txt and the rest of the script cannot be guaranteed to work properly. Keep that in mind please. Always check the log file and in case of large scripts, debug and fix from the top.
Standard function structure
There are plenty of functions available, but let's look at a standard way a function is formed and executed.
mainObject accessor function parameter1 parameter2 parameter3 ... ;
Not all functions follow this format, but most of them do. Let's look at some examples.
PrintMessage This_will_be_printed_out_in_the_PatronLog.txt ;
The above is a very simple function, very useful for debugging to see which part of a script was reached or indeed which script was executed in general. The function has only two parts:
- PrintMessage - function name; global namespace since it has no specific accessor
- This_will_be_printed... - the value; what is typed here as the parameter will be printed out. Notice that there are no empty spaces!
Every function MUST end with a semicolon ";".
Example 2: Formatting an event display
int eventId = 0 ; event GetById eventId PanelSetCaption CAP_Cold ; event GetById eventId PanelSetDescription EV_TEST2_Intro ; event GetById eventId PanelAddAnswer 0 EV_TEST2_AN_A ; event GetById eventId PanelAddAnswer 1 EV_TEST2_AN_B ; str picturePath = Data\Textures\Icons\EventsIcons.dds ; event GetById eventId PanelSetPicture picturePath 512 0 ;
The above block of code is called when an event is triggered. The block populates the various parts of the events panel (texts, picture, answers...). If you're interested in changing existing events or creating new ones, we have an article dedicated to that specific topic.
This is just a quick, shallow overview of the script engine. If you're interested in scripting Patron, please go over all the other articles to get a proper handle on things. A good advice would be to start with the basics: the variables.