The packages on Onset allow you to quickly and easily add content created by the community to your server. A package contains a set of files (LUA, HTML, CSS, JS, Images) required for the operation of the task for which it was designed. It can also be a dependent of another package.
Using a package
To use a package on your server, you need to upload your package in onset/packages
folder.
After, configure the list of packages used on your Onset server (edit the packages
section of the configuration file) and restart your server.
LUA execution context
Technically, each package has its own LUA execution context (LuaVM state), whose execution is separate from that of the other packages.
LUA script files loaded in the same package can access the same global variables. Local variables are only accessible in the LUA file where they are defined, so you will not have access to them in another LUA file.
A system allows the export of the functions of one package and the import/use in another package.
Package limitations
There are several limitations:
- you can only load up to 32 packages.
- a package cannot contain more than 255 files.
- a maximum of 64 client scripts in the package.
- the package must not exceed 2GB.
Authorized files
The following are the file extensions allowed in a package: lua, js, css, html, htm, png, jpg, jpeg, gif, wav, mp3, ogg, oga, flac, woff2, ttf, pak.
Package structure
The packages used on your server must be in the server's packages
directory.
Within this folder, each package must have its own folder.
The following is the file structure of a package::
HorizonServer.exe server_config.json /packages /mypackagename package.json /mapeditor package.json /client editor.lua /server server.lua
The package.json file
Each package contains a specific package.json configuration file at the root of its folder, which is loaded by the server when it starts.
It defines the server and client script files and also the files that are required for the package to work.
The files defined in client_scripts
are the files that will be downloaded by players after joining the server.
{ "author": "Blue Mountains", "version": "1.0", "server_scripts": [ "server/editor.lua" ], "client_scripts": [ "client/editor.lua" ], "files": [ "client/gui/editor.html", "client/gui/editor.css", "client/gui/editor.js", "client/gui/jquery.js", "client/gui/OpenSansRegular.woff2", "client/gui/OpenSansBold.woff2" ] }
Package cache
Files downloaded from servers are cached on the client folder %appdata%\..\Local\Horizon\Saved\ServerContent
. That way, the files are downloaded only once.
If you modify a file on the server, the checksum (signature) of the package will change.
The customer will detect the change and download the new version.
Sample package
Here is an example of a package published by the game developer:
https://github.com/BlueMountainsIO/OnsetLuaScripts
Official wiki
Go to the official documentation here.