Torch Plugin Template

From Torch Wiki
Jump to navigation Jump to search

This page describes, how to import the Torch plugin template into your Visual Studio, and creates a step by step guide on how to set up your project with it.

Don't worry, it will be quite simple.

Download the template

The Template is located here:

File:Torch Plugin

Import the template to Visual Studio

You find your Visual Studios files located within your Documents folder.

Documents folder vs.png

Inside it you find a folder 'Templates' and inside that 'ProjectTemplates'.

All you need to do is to drop the zip file in there as shown below.

Documents vs template folder.png

Alternatively you can get to it using C:\Users\marti\Documents\Visual Studio 2019\Templates\ProjectTemplates

In case you don't use VS 2019 you of course have to change the version.

Now the template is properly installed and you can start using it. Be careful, you may have to restart Visual Studio before it shows up.

Create your Project

When you create a new project, you can now search for Torch in your templates.

Template new project torch.png

Simply select it and proceed normally like with every project.

It is recommended to use a simple name, preferably without spaces and special characters. (Yes German umlauts are special characters).

Template meaningful name.png

In this example we call our project 'Demo'

Once the project is created your project explorer looks like this:

New project from template.png

However you are not done yet, since the references are still broken.

New project broken references.png

Setup project references

To fix the references first you have to close the project and go to its location on your disk.

Project directory template.png

you will notice this obvious Setup bat file. when you run it, it will ask for the locations of the Space Engineers Dedicated Server and Torch. Don't worry, if you have Torch installed and started up once it comes with everything you need.

New project setup bat.png

Of course the path to your Torch directory will be different, but the DedicatedServer64 folder will still reside inside Torch.

Once executed you see 2 new symbolic links in your project.

Project directory template with references.png

You can now open your solution again, and the reference errors should be gone.

New project broken references begone.png

It may take a while, till VS updates the references in the project explorer. After opening a class it was ~10 seconds till the compile errors vanished.

Build your plugin

The plugin itself is already pretty much done. Once the compile errors are gone, you can already build it.

Template build successful.png

You get two outputs:

First you get the plugins dll, pdb and manifest.xml in your 'bin' directory.

Template build bin.png

And you get a zipped plugin, ready to upload to Torch or to copy in your servers plugin folder in the 'Build' directory.

Template build build.png

Read the README

The README file contains some information about what is already set up for you, and what the different files do. Apart from that its setup guide is a bit more simplistic than this one here.

After you have read it you can dispose of it.

The Setup bat you may want to keep, in case you are moving your project to a different folder, or plan to share it through Github. In that case other people may need it to set the project on their own machine.


Don't forget to add the symlinks to your gitignore file later, otherwise Github will not be happy about the size of your project, as it would contain the entirety of Torch.

we added a .gitignore file to the template, hoping to prevent that from happening.


You are now prepared to convert this template into your very own plugin.

Good Luck!