This library contains quality of life functions to ease development of script (LUA) based mods for Farming Simulator 22 (FS22).
- ModHelper - A base class/bootstrapper for any script based mod
- LogHelper - Quality of life class/library for logging and debugging
- DebugHelper - Extension to the LogHelper that is particularly useful when debugging
- FillTypeManagerExtension - Extension class to the FillTypeManager that enables your mod to add custom fill types and height types (material that can be dumped to ground)
I love to hear you feedback so please check out my Facebook. If you want to support me you can become my Patron or buy me a Ko-fi ❤️
2. Create a script file (if you haven't already), e.g. "YourModName.lua", with the following content:
YourModName = Mod:init() -- "YourModName" is your actual mod object/instance, ready to use
<sourceFile filename="lib/ModHelper.lua" />
It shoud look something like this:
<extraSourceFiles>
<sourceFile filename="lib/ModHelper.lua" /><!-- Must be above your mod lua file -->
<sourceFile filename="YourModName.lua" />
</extraSourceFiles>
4. Now your mod is ready to be used, e.g. you could att these lines to "YourModName.lua" to print a text when your mod is loaded:
function YourModName:loadMap(filename)
print("Mod loaded")
end
Some more events that can be used similar to loadMap:
loadMapFinished()
- This event execute after the actual map has finished loading and before other mods are loaded (withloadMap
)startMission()
- When user selects "Start", execute after bothloadMapFinished
andloadMap
update(dt)
- Looped as long game is running (CAUTION! Anything in here will constantly execute and might severly affect performance)
The Mod
class will automatically add a number of field/properties to your for convinient access, e.g.
local authorsName = myMod.author -- The name is automatically read from the modDesc file
dir
- The mod directory, i.e. folder or zip file on disk (same asg_currentModDirectory
)name
- The name of your mod (i.e.g_currentModName
)title
- The english title of your mod (from modDesc.xml)author
- The author node from modDesc.xmlversion
- The version node from your modDesc.xml
The Mod
class will automatically add a number of functions/methods to your mod for convinient access, e.g.
local aSound = myMod:loadSound("SoundName", "/sounds/aSound.ogg")
loadSound(name, relativeFilename)
- Loads a sound/sample (automatically appends the mod.dir path to the filename)trySource(relativeFilename, [silentFail])
- Will try to load/source a LUA script file if that file exists, automatically adding mod.dir path to the filename, and with optional "silent fail" (no error message if file is missing)
Built-in (semi-)automatic support to read and write user settings.