Skip to content
Anthony Roy edited this page Aug 31, 2016 · 3 revisions

Now that the mod is successfully setup with the proper dependencies and property settings we can start building our main function.

As stated earlier this main will be the BARE basics of what is required to get the mod to successfully be injected by NMSE. If you wish to see more complex examples, please see the more advanced tutorials or look through NoHUD or other projects that aren't directly apart of the NMSE core (at the moment that would be: TabbingFixExample, NoHUD and StackResize).

So to start open up the C++ (cpp) file created earlier. I called it Source but I'd HIGHLY recommend calling it something else as you'll likely have 6+ files open at a time (if you really get into it).

Includes

So earlier, if you noticed, we set "Force Includes" to include "NMSE_Libs/DefStuff.h". If you look at this file, it actually has a fair amount of everything you'll need such as windows headers, iostream headers, string headers etc.

That being said the include we are going to need at the moment is: "NMSE_Core_1_0\ModAPI.h"

Main Function

Now the Main function for NMSE goes like this:

extern "C"
{
	bool OnStart(HMODULE& mHandle, ModDetails& info){
		info.name = "Your Mod Name";
		return true;
	}
};

Now at this point your Main is technically functional but let's do a little bit of safe checking. It's usually a good idea to keep track of the handle. So adding that and a little MessageBox to come up to alert you that it has loaded we get this for our main:

#include "NMSE_Core_1_0\ModAPI.h"

HMODULE modHandle;

extern "C"
{
	bool OnStart(HMODULE& mHandle, ModDetails& info){
		modHandle = mHandle;
		info.name = "Example Project";
		// Please don't keep this in when posting actual mods!
		MessageBox(0, "Hello World!", info.name.c_str(), MB_OK);
		return true;
	}
};