Skip to content

Tutorial one: Creating your first mod.

Asdew edited this page Feb 22, 2018 · 5 revisions

Hi there modder,

Got setup and are ready and on fire to smash that keyboard like you've never done before?
We got good news for you, you don't have to.
We've made sure it's as easy as possible to create mods!

First you open your preferred IDE. (Notepad++ is NOT an IDE. It is a text editor.).
You create a new C# Class Library project since we want our output to be a .dll file.
Then you import UnityEngine.dll and Assembly-CSharp.dll.
When you got your first class in it should/could look like this:

	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;

	namespace TestMod1
	{
		class I_Do_not_know_da_wae
		{
		}
	}

It doesn't? Well then don't use Notepad++ for F*** sakes!
We have been so nice to create a MyMod class for you to setup a good template.
So you change your main class to this:

using SFSML;
using SFSML.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestMod1
{
    [MyModEntryPoint] //This tells the modloader this is the class that implements MyMod and is your main class
    class I_Do_not_know_da_wae : MyMod
    {
        public I_Do_not_know_da_wae() : base("{MOD NAME}","{MOD DESCRIPTION}","{MOD VERSION}")
        {
            //Only assign variables here. Doing mod related things might result in errors!
        }
        protected override void onLoad()
        {
            //Do shit here
            ModLoader.mainConsole.log("Hello world", "My Cool Log Tag");
        }

        protected override void onUnload()
        {
            //Not in use at the moment. Will never be called. Don't worry
        }
    }
}

Now you compile your awesome mod.
You place it in %your game directory%/%sfs name% data/SFSML/mods/normal/
Restart the game and look how good your dev skills are!!
-> Tutorial two: Adding a config.