The unofficial extension to the base game Lua library, adding new features and quality-of-life helper libraries, making this your one-stop-shop and starting point for all your mods.
With a non-intrusive opt-in approach running in the mod sandbox you can safely add this to any mod without any risk of version conflicts or bloating your mod. You choose what features to enable and to what extent you want to utilize the library.
If you have any suggestions, find an issue or maybe even have your own nifty functions you want to share with others, we gladly accept your contribution (see the Contribute section below for options and details).
Quick links: Installation | Getting Started | Script Reference
To install the FS Script Library you have three options:
The quickest way to get started with a new mod is the Bootstrap Mod that is the foundation for a complete ready-to-run mod with FS Script Library already installed.
To add script library to an existing mod, the automatic (B) or manual installation (C) is recommended.
- Download the latest archive
- Unzip the zip archive to the root of your mod folder, it should look like this:
yourMod\
scripts\
scriptLibrary\
...
scriptLibrary.lua
ModHelper.lua
YourMod.lua
- Follow the instructions in the Getting Started section.
1. Install FS Script Library to your mod
2. Add the scriptLibrary.lua file to the <extraSourceFiles> section of your modDesc.xml:
<extraSourceFiles>
<sourceFile filename="scripts/scriptLibrary/scriptLibrary.lua" />
</extraSourceFiles>`
3. Uncomment the files you want to include from the scriptLibrary.lua file, e.g:
-- ### Specializations (disabled by default) ###
source(g_scriptLibraryDir .. "defaultDisabled.lua")
--source(g_scriptLibraryDir .. "alsoDisabledByDefault.lua")
4. Create your main mod script file (e.g. MyMod.lua) and add it to the <extraSourceFiles> section of your modDesc.xml
5. [optional] Add the following snippet to your main mod script file:
-- Creates a new mod object (listening to mod events such as loadMap etc)
YourModName = Mod:init()
-- Executed when the map has finished loading, a good place to begin your mod initialization
function YourModName:loadMap(filename)
print("Map is loaded")
end
6. Try your mod
Note: Using the Mod
helper class in step 5 is optional, you can create the mod however you like, this is just the quick and easy way to get started.
Folder | File (.lua) | Description |
---|---|---|
(no folder) | ||
scriptLibrary | This is the main script for the FS Script Library, this file contains a reference to all possible other files, uncomment the files you want to include. | |
ModHelper | QoL wrapper and helper library to create your script mod, this serves as a good starting point for all mods, see documentation for all available functions and properties provided by the helper class. | |
ui | UI/HUD related scripts | |
placeables | Classes and utility scripts related to placeables | |
specializations | Vehicle and placeable specializations | |
extensions | General extension to base game classes | |
utils | Helpers classes, e.g. to extend the string class or utilities for debugging | |
misc | Other scripts not matching any of the above categories | |