packages: Difference between revisions

From Onset Developer Wiki
Created page with "A package is collection of Lua scripts and other files. You can have up to 32 packages and 255 files per package. ==Lua context== Each package has their own LuaVM state. Lua..."
 
No edit summary
Line 1: Line 1:
A package is collection of Lua scripts and other files.
A package is collection of Lua scripts and other files. You can have up to 32 packages and 255 files per package on your server.
You can have up to 32 packages and 255 files per package.
 
Allowed file type extensions: '''lua, js, css, html, htm, png, jpg, jpeg, gif, wav, mp3, ogg, oga, flac, woff2, ttf, pak'''
 
Example packages: https://github.com/BlueMountainsIO/OnsetLuaScripts


==Lua context==
==Lua context==
Line 6: Line 9:


==Folder layout==
==Folder layout==
Each package has a folder that is placed inside the '''packages''' folder on your server.
<pre>
<pre>
OnsetServer.exe
OnsetServer.exe
Line 12: Line 16:
         /mypackagename
         /mypackagename
             package.json
             package.json
         /freeroampackage
         /mapeditor
            /client
                editor.lua
            /server
                server.lua
             package.json
             package.json
</pre>
</pre>

Revision as of 14:56, 11 September 2019

A package is collection of Lua scripts and other files. You can have up to 32 packages and 255 files per package on your server.

Allowed file type extensions: lua, js, css, html, htm, png, jpg, jpeg, gif, wav, mp3, ogg, oga, flac, woff2, ttf, pak

Example packages: https://github.com/BlueMountainsIO/OnsetLuaScripts

Lua context

Each package has their own LuaVM state. Lua script files that are loaded in the same package can access the same global variables.

Folder layout

Each package has a folder that is placed inside the packages folder on your server.

OnsetServer.exe
server_config.json
    /packages
        /mypackagename
            package.json
        /mapeditor
            /client
                editor.lua
            /server
                server.lua
            package.json

package.json

Your package.json defines server and client script files. It also defines what files are required for this package to work. Files defined in client_scripts and files are being downloaded by clients once they join the game 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"
	]
}

Each package has a package.json in it's root path. See the folder layout above. Additionally you have to tell the server what packages exist. See server_config to configure that.