Because Bannerlord uses .Net framework for its gameplay functionality, we can use Visual Basic .Net if you're not fond of C# or just doesn't like curly brackets.
To start, create a VB.Net Framework Class Library project.
Make sure you choose the correct .Net framework target. Bannerlord uses version 4.7.2
Right click on reference and add click Browse...
Go to your bannerlord.exe location and add all Taleworlds.* dll
Click OK.
After you added the Reference don't forget to set them not to be copied during compilation process as this may interfere with your mod (loading wrong assemblies) or copyright infringement
Make sure your namespace starts with Global !
Otherwise the engine won't recognise your class Entry point (which is class you inherit with MBSubModuleBase.
Now let setup the project, debug options, and your module manifest data.
Create a new directory in Bannerlord Module in highlighted path:
And makes sure your compiled dll is located in that directory!
In Modules\MyVBProject\ we create mod manifest file: SubModule.xml
Now let's setup debug parameter:
Start external program: Put your TaleWorlds.MountAndBlade.Launcher.exe (NOT BANNERLORD.EXE) location here
Command line arguments: leave it empty
Working directory: The bin location where TaleWorlds.MountAndBlade.Launcher.exe resides. If you leave this blank you'll crash.
Save the VB project.
Run the program.
Make sure you load appropriate project in the launcher (MyVBProject)!
If you see this screen, congrats your mod works!
Remember: To every time you write Namespace, don't forget to put Global prefix like so: Namespace Global.MyVBProject
Thanks for reading, glhf programming bannerlord in VB.net
To start, create a VB.Net Framework Class Library project.
Make sure you choose the correct .Net framework target. Bannerlord uses version 4.7.2
Right click on reference and add click Browse...
Go to your bannerlord.exe location and add all Taleworlds.* dll
Click OK.
After you added the Reference don't forget to set them not to be copied during compilation process as this may interfere with your mod (loading wrong assemblies) or copyright infringement
Code:
Imports TaleWorlds.Core
Imports TaleWorlds.MountAndBlade
Namespace Global.MyVBProject
Public Class MySubModule
Inherits MBSubModuleBase
Protected Overrides Sub OnSubModuleLoad()
MyBase.OnSubModuleLoad()
End Sub
Protected Overrides Sub OnBeforeInitialModuleScreenSetAsRoot()
MyBase.OnBeforeInitialModuleScreenSetAsRoot()
Dim ver = System.Environment.Version
InformationManager.ShowInquiry(New InquiryData(
"Net Enviroment",
$"running on version {ver}",
True,
False,
"Accept",
"",
Sub()
'Environment.Exit(1)
End Sub,
Sub()
End Sub))
End Sub
End Class
End Namespace
Make sure your namespace starts with Global !
Otherwise the engine won't recognise your class Entry point (which is class you inherit with MBSubModuleBase.
Now let setup the project, debug options, and your module manifest data.
Create a new directory in Bannerlord Module in highlighted path:
And makes sure your compiled dll is located in that directory!
In Modules\MyVBProject\ we create mod manifest file: SubModule.xml
XML:
<?xml version="1.0" encoding="utf-8"?>
<Module>
<Name value="MyVBProject"/> <!-- this is your project name -->
<Id value="MyVBProject"/> <!-- this is your project Id, it can be unique string or just use your project name -->
<Version value="v1.0.0"/> <!-- your project version -->
<SingleplayerModule value="true"/>
<MultiplayerModule value="false"/>
<Official value="false" />
<DependedModules/>
<SubModules>
<SubModule>
<Name value="MyVBProject"/>
<DLLName value="MyVBProject.dll"/> <!-- this is your assembly file name in bin (or dll name) -->
<SubModuleClassType value="MyVBProject.MySubModule"/> <!-- this is your entry point!, a namespace followed by your class entry point. if you're using VB.net MAKE SURE TO PUT GLOBAL PREFIX IN NAMESPACE, otherwise the game cannot locate it, it's VB.net quirk -->
<Tags>
<Tag key="DedicatedServerType" value="none" />
<Tag key="IsNoRenderModeElement" value="false" />
</Tags>
</SubModule>
</SubModules>
<Xmls/>
</Module>
Now let's setup debug parameter:
Start external program: Put your TaleWorlds.MountAndBlade.Launcher.exe (NOT BANNERLORD.EXE) location here
Command line arguments: leave it empty
Working directory: The bin location where TaleWorlds.MountAndBlade.Launcher.exe resides. If you leave this blank you'll crash.
Save the VB project.
Run the program.
Make sure you load appropriate project in the launcher (MyVBProject)!
If you see this screen, congrats your mod works!
Remember: To every time you write Namespace, don't forget to put Global prefix like so: Namespace Global.MyVBProject
Thanks for reading, glhf programming bannerlord in VB.net
- Debug parameter is prone to glitch during debug, repalce Bannerlord.exe with the launcher executable.
- Added guide to remove unnecessary DLL copying, as this may lead to loading wrong module and copyright issue during publishing.
I think you can also write mod with F#, maybe next guide I guess :^)
Last edited: