Skip to content

w33zl/FS22_WeezlsModLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Weezl's Mod Lib for Farming Simulator 22

This library contains quality of life functions to ease development of script (LUA) based mods for Farming Simulator 22 (FS22).

Contents/features

  • 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)

Like the work I do?

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 ❤️

ko-fi Support me on Patreon

ModHelper

1. Copy the "lib" folder to the root folder of your mod

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

3. Add this line to the <extraSourceFiles> section of your ModDesc.xml file:

<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 (with loadMap)
  • startMission() - When user selects "Start", execute after both loadMapFinished and loadMap
  • update(dt) - Looped as long game is running (CAUTION! Anything in here will constantly execute and might severly affect performance)

Built-in properties in your mod

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 as g_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.xml
  • version - The version node from your modDesc.xml

Built-in functions in your mod

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)

Automatic support for user config file

Built-in (semi-)automatic support to read and write user settings.

About

This library contains quality of life functions to ease development of script (LUA) based mods for Farming Simulator 22 (FS22)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages