When making a new plugin, make sure you set up your plugin's folder as follows:
OpenplanetNext/
├── Plugins/
│ ├── <PluginName>/
│ │ ├── info.toml
│ │ ├── build.bat
│ │ ├── src/
│ │ │ ├── <your code>.as
Here, "PluginName" is the name of your plugin, "your code".as would be your code files.
This structure is important for the build process because it allows our build script to take the info.toml file and the files in the src folder as input.
As you seen in the structure, the build.bat file is the build script for your plugin.
Create a new file called build.ps1 in your plugin's folder and use this code below:
:: We will hide our commands
@echo off
:: Set here your path to 7-Zip, including 7z.exe
SET zip="C:\Program Files\7-Zip\7z.exe"
:: This will get the current directory name,
:: Keep in mind that the Plugin ID (not the site ID) must be the same name as the current directory
for %%I in (.) do SET CurrDirName=%%~nxI
:: Check if we have already a .op built
:: If we have one, we need to delete, because 7-Zip will add files on it but not delete older ones
IF EXIST %CurrDirName%.op (
del %CurrDirName%.op
)
:: Then compress it
%zip% a -mx1 -tzip %CurrDirName%.op info.toml src
echo Done!
On your VS Code workspace, create a new task.json file.
- Open your command palette with F1.
- Select "Configure Task" from the "Tasks" category.
- Select "Create tasks.json file from template".
- Select "Other"
This will create a new task.json file in your workspace. Now replace this json to make run your bat script.
{
"version": "2.0.0",
"tasks": [
{
"label": "Build .op file",
"type": "shell",
"command": "${workspaceFolder}/build.bat",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Don't forget to add the "group" property to your task so it will be a default build task.
To run your build task, open the command palette with F1 and select "Run Build Task".
You can make a keyboard shortcut for this command. By default, it is Ctrl+Shift+B
.
You can now publish your plugin to the Openplanet website.