First Plugin
An Explanation how to start with creating Synapse SL Plugins
Requirements
You need the following things for creating a Synapse Plugin:
A program/IDE for programming and compiling C# Code (Visual Studio/ Rider)
A (local) SCPSL Server for testing Plugins. Can be installed with Steam
All required Dependencies for Synapse/SCPSL or our NuGet
For those who are new to developing with C#:
A NuGet is something like a Package that includes everything your IDE needs for creating a Plugin without the need of you searching and linking up all required dependencies for creating a Plugin
Therefore, you obviously should install it as your first Step after creating a new Project inside your IDE
How can I install the NuGet?
It depends on your IDE but here is the guide for Visual Studio, and it should be almost the same for all IDE's
Click on Project (A button on the top left of your Window)
Click on Manage NuGet packages
Click on Browse
Type
SynapseSL
inside the Search fieldClick on SynapseSL (most likely the first and only NuGet Available)
Optional: Select the Version of Synapse you want to install (latest by default)
Click on Install
First Lines of Code
Now that you have all required dependencies, can you start with creating your Plugin!
Foremost, you need to create a new Type/Class that Inherits from Neuron.Core.Plugins.Plugin
The second Requirement for a Plugin is to add the Plugin Attribute to your Class so that Neuron/Synapse can get all the information it needs about your Plugin
This should look like this:
This Plugin would already load when compiled and placed inside your Plugin Directory, however it would do nothing except for existing, so next we are going to override the Load
and Enable
method
You can already see that we added Logger.Info()
inside both of the methods, which means these messages will be displayed inside your Server Console on Loading/Enabling your Plugin but
What is the difference between Load() and Enable()
It's actually quite Easy
Load is called one time when the Plugin Class was just created before anything else, so you can use it similar to a constructor to initialize everything you need. However, keep in mind that injected fields are not yet injected and therefore can't be used. What Injected Fields are will be explained on the next page
Enable can be called multiple times theoretically and is called to enable your Plugin after all Meta based processes like creating objects with the Automatic Annotation are finished. Use this method to actually enable your plugin. However, due to the nature of SL we don't support disabling plugins currently, therefore it will normally only be called once
You have maybe noticed there is also an Disable Method which should do the oppsoite of Enable and "revert" everything that Enable does, however as said before we doesn't support this currently
Last updated