Creating new addons

From Pragma
Jump to: navigation, search

Before reading this tutorial it's recommended to set up ZeroBrane, which will allow you to work and debug with Lua more easily.

Description

To create a new addon all you have to do is create a new directory inside "addons" relative to your game directory.
You can add all of the addon resources, Lua-scripts, etc in that directory and it will be automatically mounted by the game. Gamemodes should also be packed inside an addon.
If you want to publish your addon on the modding hub, you'll have to pack your addon into a PAD-file.

Creating a PAD-file

PAD ("Pragma Addon Data") files are the only type of files which can be uploaded to the modding hub.
They contain the addon data in compressed form, Lua-scripts are automatically pre-compiled for faster loading and they contain additional version information.
First, create an empty text-file in the "addons"-directory (Not inside your addon!) and add the following:

addonName/**

Replace "addonName" with the directory name of your addon. The "**" recursively includes all files within the addon to the archive. A "*" would only include all files on the first level. You can also specify multiple targets and specific files.
Save the file, then drag-and-drop it onto the "pad.exe" inside the "bin" directory relative to your game directory.
It should generate a ".pad"-file with the same name as the text-file. The names of the text-file and the .pad-file have to be the same, so don't change them (or change them both if you do).

All .pad-files within the "addons" directory are also automatically mounted. You can now also publish it to the modding hub.
Note: Make sure to keep your original .pad-file, the one you can download from the modding hub after you've published your addon won't be the same!

Updating your addon

To update your addon, simply drag-and-drop the text-file onto the "pad.exe" again. Make sure your previous .pad-file is in the same directory when you do.
You can upload the file to the modding hub and overwrite the previous version. Everyone who has downloaded the addon will receive the update automatically. (They will only have to download the files which have been changed in the update.)
By default the version will be incremented automatically (Starting at 0.0.1), but you can specify your own version by running the "pad.exe" from the command line:

pathToPragma/bin/pad.exe pathToAddon/addon.txt -version=1.5.0

Note: Once you've published a certain version, you can never go back to lower version numbers!

Extracting an addon

To extract a .pad-addon, you can simply drag-and-drop the .pad-file onto the "pad.exe" in the bin-directory and it'll extract all files into a directory called "extracted" where the .pad-file is located.