gitlabEdit

Modding-guide

What is the mod for the kernel?

The mod is the source code file that loads on boot, and can add extensions to the kernel, the shell, and everything. It can also respond to events. However, the mod can only have one command, and a command code.

This is useful if you want to add your own extensions to the kernel, like event handlers for the kernel.

Can I make my own screensaver?

Yes, but first check out "usermanual Screensaver modding guide" manual page for instructions on how to add your screensaver.

Basic modding

How to make your own mods on Visual Studio 2017?

  1. On the Start Page, click on New Project

  2. Click on Empty Project, select VB or C#, and name your mod or modpack. Make sure the project directory is set to your KSMods directory in your home folder. When you're finished, click OK.

  3. Right-click on References on the Solution Explorer, and press Add Reference...

  4. Click on the Browse... button, and locate your Kernel Simulator executable file (the file you just ran)

  5. When you click OK on Open File, you will see that your KS executable files is added to the reference list.

  6. Make sure it has the checkbox that is checked on it, and click on OK.

  7. Right-click on the project, not the solution

  8. Change the application type to Class Library

  9. On the Compile section, click on Build Events, then write this on the Post-build event command line:

    • If you are using VB:

  • If you are using C#:

  1. Make sure the post-build event runs only when the build is successful

  2. Save everything by pressing CTRL+S

  3. Expand the References section on the Solution Explorer

  4. Set the Copy Local setting to False as you have the executable so you don't make an extra copy

  5. Right-click on the project, and go to Add > Class

  6. Assume that you're making a mod in VB. Name your mod, but leave the .vb intact. Your mod name should be the one that is included in the Post-build built event. If your mod name is changed, you must also change the post-build event for the changes to be reflected.

  7. Click Add, and the code will be ready:

  1. Between the Public Class... and the End Class lines, let Visual Studio 2017 know that you're going to create your KS mod by writing: Implements IScript

  2. If you're going to add namespaces, these rules must be met:

    1. Don't import "KS" by itself. KS does that automatically

    2. When importing modules/classes like TextWriterColor, it's written like this: Imports KS.TextWriterColor

  3. Define properties for mod information by putting below the Implements IScript: Property Cmd As String Implements IScript.Cmd Property Def As String Implements IScript.Def Property Name As String Implements IScript.Name Property Version As String Implements IScript.Version

  4. Make your start mod sub named StartMod() that implements the IScript.StartMod, by writing:

  1. Replace every Your code below comment with your code. Repeat this step on all the interface subs

  2. Make your mod stop sub named StopMod() that implements the IScript.StopMod, by writing:

    1. If you're making your command in your mod, write the response code below:

    1. If you're making your event handler which handles what happened in the kernel, write the handle code below:

25. You can make your subs anywhere on the class, but if: 1) they're on the different class, press Enter on End Class and make a public new class that stores new subs:

26. Run the build. When the build is successful, ignore the dialog box that appears. 27. Run your Kernel Simulator you've just referenced to in your project.

  1. Hello World on Kernel Start, and Goodbye World on Kernel Stop

Hello World is the popular starting example for all of the programmers. These examples usually start with printing the "Hello World" string to the console output or command prompt. To make your first Hello World mod, follow these steps:

  1. Right-click on the project, and go to Add > Class

  2. Name your mod, but leave the .vb intact. Your mod name should be the one that is included in the Post-build built event. If your mod name is changed, you must also change the post-build event for the changes to be reflected.

  3. Click Add, and the code will be ready.

  4. Write below the (Assume that your mod name is HelloGuys) Public Class HelloGuys: Implements IScript

  5. Write above the Public Class HelloGuys:

  1. You should get errors saying that these subs should be created.

  2. Make your start mod event handler by writing:

  1. Make your stop event handler by writing:

  1. Since we're not implementing commands nor event responders, we're going to leave these blank:

  1. The code should look like this in VB:

...Or in C#:

  1. Run the build. When the build is successful, ignore the dialog box that appears.

  2. Run your Kernel Simulator you've just referenced to in your project.

  3. Hello World on command execute

  4. Repeat the steps 1-5 on the first example: Hello World on Kernel Start and Goodbye World on Kernel Stop

  5. Make your start mod event handler by writing (assuming that your mod name is HelloShell):

  1. Since we're not implementing shutdown handler nor event responders, we're going to leave these blank:

  1. Make your command handler, and let it respond to the SayHello mod command:

  1. The code should look like this in VB:

...Or in C#

  1. Repeat the steps 11-12 on the first example: Hello World on Kernel Start and Goodbye World on Kernel Stop

  2. Hello World on command execute with arguments (single)

  3. Assuming that your mod name is HelloArgs, your argument that will make your command say Hello World is HW, and that your command is SayHello, Repeat the steps 1-3 on the second example: Hello World on command execute

  4. Make your command handler, and let it respond to the SayHello mod command:

  1. The code should look like this in VB:

...Or in C#:

  1. Repeat the last step on the second example: Hello World on command execute

  2. Hello World on command execute with multiple arguments

  3. Assuming that your mod name is HelloArgs, your argument that will make your command say Hello World is Say Hello, and that your command is WhatDoISay, Repeat the steps 1-3 on the second example: Hello World on command execute

  4. Make your command handler, and let it respond to the WhatDoISay mod command:

  1. The code should look like this in VB:

...Or in C#:

  1. Repeat the last step on the second example: Hello World on command execute

  2. Network Speed Testing

  3. Assuming that your mod name is InternetSpeed, and that your command is getnetspeed, Repeat the steps 1-3 on the second example: Hello World on command execute

  4. Put these namespaces above the file:

  1. Make your command handler:

  1. The code should look like this in VB:

...Or in C#:

  1. Repeat the last step on the second example: Hello World on command execute

More examples

If you want to check out more examples, feel free to check them out in the KSModExamples respository in GitHub (Not available yet).

Sources:

Last updated