-
Notifications
You must be signed in to change notification settings - Fork 3
Creating Plugins
The BPO Plugin System is a powerful framework that allows developers to extend the functionality of BPO using Lua scripts. This documentation provides an overview of the BPO Plugin System, its requirements, and guidelines for developing plugins.
To use the BPO Plugin System, ensure that you meet the following requirements:
-
BPO Platform: The BPO Plugin System is designed to work with BPO. Make sure you have a compatible version of BPO installed.
-
Lua: The BPO Plugin System utilizes the Lua programming language. Familiarity with Lua is required to develop plugins effectively.
When developing plugins for the BPO Plugin System, please adhere to the following guidelines:
-
Single File: Although it is not mandatory, it is recommended to keep the plugin code in a single file for easier management.
-
Lua Packages: The BPO Plugin System does not support the usage of LuaRocks packages. All required Lua modules should be included directly in the plugin code or provided as dependencies within the BPO platform.
-
Plugin Schema: The plugin schema defines the structure of a plugin and its expected inputs and outputs. The plugin schema used in the BPO Plugin System is the same as jma's Project GLD. The schema should follow the JSON below:
[
{
"name": "Minecraft",
"links": [
{
"link": "https://minecraft.net"
}
]
}
]
-
name
: Represents the name of the game gathered by the plugin. -
links
: An array of links related to the game.
-
Returning Values: To send a value from the plugin to the BPO backend, create a global variable named PluginReturn and store the value in a serialized JSON format. BPO will read this variable and process the returned value accordingly.
-
Plugin Info: To make BPO find that a plugin exists, the plugin must contain a file named
plugin_info.json
on the same folder where the plugin is placed, the data must be formatted the way below:
{
"name": "Plugin Name",
"description": "This is a sample plugin on the docs!"
"author": "Mr Deez",
"source": "https://example.com"
}
Example Plugin Code: Consider the following example as a basic template for developing a plugin within the BPO Plugin System:
-- Let's supose we called a API and this is what was returned
local return_from_api = {
{
gameName = "Minecraft",
gamePub = "Mojang",
gamePage = "https://minecraft.net"
},
{
gameName = "Rust",
gamePub = "Facepunch",
gamePage = "https://facepunch.com/games/rust"
},
{
gameName = "Bloons TD6",
gamePub = "Ninja Kiwi",
gamePage = "https://store.steampowered.com/app/960090/Bloons_TD_6/"
}
}
-- Now we will select the data we want to actually use
local ret_table = {}
for _, v in pairs(return_from_api) do
table.insert(ret_table, {
name = ret_table.gameName,
links = {
{
link = ret_table.gamePage
}
}
})
end
-- Great! Now we will serialize it with a hypothetical json lib
PluginReturn = json.serialize(ret_table)
In this example, the plugin gathers games from a hypothetical API. The plugin performs some operations, creates a result object, serializes it as JSON, and assigns it to the PluginReturn global variable.
Currently there is no in-app way to install plugins to BPO, But it is possible to do it manually by copying the plugin files (plugin.lua + plugin_info.json) into:
- macOS/Linux:
~/.local/share/io.github.blackpearlorigin/plugins/<plugin-name>
- Windows:
%localappdata%\io.github.blackpearlorigin\plugins\<plugin-name>
The BPO Plugin System provides a flexible framework for extending the functionality of BPO. By following the guidelines outlined in this documentation, developers can create powerful plugins using Lua scripts. The plugin schema, returning values through PluginReturn, and adherence to best practices ensure seamless integration with BPO.
© 2023, Black Pearl Origin