This guide will walk you through creating a new mixin library for the MDK Package Libraries repository using Visual Studio Code and the command line.
Hey, thanks for wanting to contribute! Sharing code with the Space Engineers community is awesome, and I really appreciate you taking the time to do it.
That said, I need to be upfront about something: By contributing here, you're responsible for your own code and licensing. I recommend using the MIT License (it's simple and everyone understands it), but you can choose whatever open-source license you want. Just make sure you actually have the right to share what you're contributing, and understand that if there are any copyright issues, that's on you to handle.
I'm not here to play lawyer or referee licensing disputes - I'm just providing a platform for the community. If you're cool with that, let's build something great together!
- Visual Studio Code
- .NET Framework 4.8 SDK
- .NET SDK (for CLI tools)
- MDK2 installed
- Git
- C# extension (ms-dotnettools.csharp)
- Go to
https://github.com/malforge/mdk2-packagesand click Fork - Open a terminal and run:
git clone https://github.com/YourUsername/mdk2-packages
cd mdk2-packages
code .Choose a library name following the format:
YourName.MdkScriptMixin.LibraryName- For programmable block scripts onlyYourName.MdkModMixin.LibraryName- For mods onlyYourName.MdkSharedMixin.LibraryName- For both scripts and mods
- In VS Code's Explorer, right-click the
librariesfolder → New Folder - Name it (e.g.,
Alice.MdkScriptMixin.DataGrid) - Open the integrated terminal (
Ctrl+`) - Navigate to your new folder and create the mixin project:
cd libraries\Alice.MdkScriptMixin.DataGrid dotnet new mdk2mixin -n Alice.MdkScriptMixin.DataGrid
In VS Code's Explorer, navigate to your mixin project folder and create these files:
- Right-click the mixin project folder → New File
- Create
_versionand enter:1.0.0 - Create
_authorsand enter your name - Create
_descriptionand enter a brief description - Create
_releasenoteswith format:- 1.0.0 Initial release - Create
readme.mdwith usage examples and documentation
Now you'll write the actual library code that you want to share with others.
- Right-click your mixin project folder → New File
- Name it (e.g.,
MyLibrary.cs) - Write your library code
- Add as many files as needed to organize your code
Example code structure:
using System;
namespace IngameScript
{
public class MyLibrary
{
public void DoSomething()
{
// Your code here
}
}
}Important:
- For script mixins: Strongly recommended to use the
IngameScriptnamespace to avoid conflicts (programmable blocks don't use namespaces, making namespace mismatches easy to cause trouble). Mixins for mods do not need to follow this convention.
Tips:
- Add as many files as needed to organize your code
- Keep code well-organized and commented
- Consider edge cases and error handling
- Make your API intuitive for other developers
The demo shows how to use your library and is required for packaging.
- Open the integrated terminal (
Ctrl+`) - Run:
dotnet new mdk2pbscript -n Alice.MdkScriptMixin.DataGrid.Demo(replace with your library name +.Demo)
- In Explorer, open the Demo project's
.csprojfile - Find the
</Project>closing tag at the bottom - Add this line just before it:
(Replace with your actual library name)
<Import Project="..\Alice.MdkScriptMixin.DataGrid\Alice.MdkScriptMixin.DataGrid.projitems" Label="Shared"/>
- Save the file
- In Explorer, open
Program.csin the Demo project - Modify it to demonstrate your library usage:
partial class Program : MyGridProgram
{
public Program()
{
// Initialize your library
var myLib = new MyLibrary();
}
public void Main(string argument, UpdateType updateSource)
{
// Show library usage
}
}- Open the integrated terminal (
Ctrl+`) - Navigate to repository root:
cd ..\.. - Build:
dotnet build --configuration Release - Check the output for any errors
- Open the Source Control view (
Ctrl+Shift+G) - Stage all changes (click + next to Changes)
- Enter commit message:
Add [YourLibraryName] mixin - Click ✓ Commit
- Click ⋯ → Push
- Go to your fork:
https://github.com/YourUsername/mdk2-packages - Click Pull requests → New pull request
- Verify base is
malforge/mdk2-packages:main - Title:
Add [YourLibraryName] mixin - Describe what your library does
- Click Create pull request
- GitHub Actions will automatically test your build
- A maintainer will review your code
- Once approved and merged, your library is automatically published to GitHub Packages
Important: By contributing to this repository, you confirm that:
- You own the copyright to the code you're contributing, OR
- You have permission to share it under your chosen license
We strongly recommend using the MIT License for maximum compatibility and ease of use. However, you may choose any open-source license. You are responsible for:
- Ensuring your code doesn't infringe on others' copyrights
- Maintaining and enforcing your chosen license
- Handling any licensing disputes
The repository maintainer does not police or enforce individual library licenses and takes no responsibility for copyright or licensing issues.
- Always include
readme.mdwith usage examples - Use semantic versioning (1.0.0 = Major.Minor.Patch)
- Test in Space Engineers before submitting
- Press
Ctrl+Shift+Pfor command palette - Use `Ctrl+`` to toggle terminal
Check out existing libraries in the repository for examples, or open an issue on GitHub!
This guide is part of the MDK Package Libraries documentation.