Plugin Creation

From LabRPS Documentation
Revision as of 13:22, 29 July 2024 by LabRPS (talk | contribs) (Created page with " {{Docnav |Localisation |Extra Python modules }} {{TOCright}} == Introduction == Plugins are used to extend the functionality of LabRPS. LabRPS has several types of plugins. For example, WindLab plugin, SeismicLab plugin, SeaLab plugin, and many others. LabRPS is already distributed with many different plugins. You can also search various plugins on the [https://labrps.com/search LabRPS official site] or the [https://github.c...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

Plugins are used to extend the functionality of LabRPS. LabRPS has several types of plugins. For example, WindLab plugin, SeismicLab plugin, SeaLab plugin, and many others. LabRPS is already distributed with many different plugins. You can also search various plugins on the LabRPS official site or the LabRPS Addons GitHub repository to see if someone has already created a plugin that suits your needs. If not, this article will guide you through the process of creating your plugin.This page will show you how to add a new plugin to the LabRPS. Plugins are containers for LabRPS features. They can be coded in C++, or in a mix of C++ and Python, which has the advantage to ally the speed of C++ to the flexibility of Python. They can be installed from the Addon Manager or installed manually by downloading from some online repository. For now, plugins cannot be developed in Python-only.

The plugin structure, required files, and locations

You need a folder, with any name you like, placed in the user Mod directory. it is recommended to give this folder the name of the plugin. The location you place your plugin folder under the Mod directory depends on the type of plugin you are developing. If you plugin is a WindLab plugin, you should put your plugin folder under /Mod/WindLabPlugins. This folder should contain a MyFirstPlugin.txt text file. This file contains meta-information describing your plugin. Just copy this file from any other existing plugin and modify it for your needs. The MyFirstPlugin.txt file is executed when LabRPS scans the directory to discover available plugins. That's all it needs for LabRPS to find your plugin.

The user Mod directory is a sub-directory of the user application data directory (you can find the latter by typing App.getUserAppDataDir() in the Python console):

  • On Linux it is usually /home/<username>/.local/share/LabRPS/Mod/.
  • On Windows it is %APPDATA%\LabRPS\Mod\, which is usually C:\Users\<username>\Appdata\Roaming\LabRPS\Mod\.
  • On macOS it is usually /Users/<username>/Library/Application Support/LabRPS/Mod/.

Your plugin folder should look like this:

/Mod/
 +-- WindLabPlugins/
                   +-- MyFirstPlugin/
                                    +-- MyFirstPlugin.txt

The MyFirstPlugin.txt file

# -*- coding: utf-8 -*-
# (c) My Name 2024

__Name__ = "MyFirstPlugin"
__Comment__ = "This plugin adds great functionalities to LabRPS"
__License__ = "LGPL v 2.1"
__Web__ = ""
__Wiki__ = "https://wiki.labrps.com/Plugin_MyFirst"
__Icon__  = ""
__Help__ = ""
__Author__ = "My Name"
__Version__ = "1.0"
__Status__ = ""
__Requires__ = ""
__Files__ = "MyFirstPlugin.dll"
__Date__ = "25-08-2024"
__Phenomenon__ = "Wind Velcoity"
__RPSVersion__ = "0.1"

You can choose any license you like for your plugin, but be aware that if you wish to see your plugin integrated into and distributed with the LabRPS source code at some point, it needs to be LGPL2+ like the example above. See License.