This article is a stub. You can help Lurkers.io Wiki by expanding it. |
This page demonstrates on how to setup ones own Lurkers.io server, including scripting custom gamemodes.
Start a basic server
First, download the latest server.jar.
Then run it with: java -jar server.jar
Additional options
Option | Description |
---|---|
headless | Runs without a graphical interface. Useful for running a dedicated server |
port | Specifies what port to run on. Defaults to 6767 |
name | The name of the server |
private | Skips registering to the master server. Note that your port must be accessible to do this anyways |
nossl | Skips SSL if there is a key.pem and a cert.pem file available |
level | Specify what level should be launched. Defaults to hazmat.tmx |
script | Specify what script should be loaded. Defaults to the script found in the level config. You can provide your own Lua script here if placed adjacent to your server.jar |
maxplayers | The maximum number of players that can join your server. Defaults to unlimited players |
Run a dedicated headless server
If you want to run a server all the time, it is useful to run your server as headless and setup a service so it will restart if it fails for some reason.
Download server_setup.sh - this is a bash script that will install a service which continuously runs your server. It requires systemd to be available.
Adding SSL
Simply add your "key.pem" and "cert.pem" adjacent to the "server.jar".
It will tell you that the certificate was found and SSL will automatically be enabled for your server.
Note that the client must be using HTTPS for this to work.
Scripting
Writing a simple gamemode
Without any script loaded, any player who joins the game will only be allowed to spectate. Most of the game rules are all scripted with Lua.
Below is an example of a sandbox gamemode where you spawn as a human with 5000 coins. There isn't too much to it, but it is very easy to expand on.
Try saving it as sandbox.lua next to your server.jar, then running the server with: java -jar server.jar script="sandbox.lua"
setup_default_game = dofile("scripts/modules/setup_default_game.lua") simple_shop = dofile("scripts/modules/simple_shop.lua") local shop = addSimpleShop() -- Sandbox gamemode Game:updateConfigs({ gameMode = "Sandbox", gameDescription = [===[There is no specific aim with this gamemode. Press B to open the shop. You start with a lot of money!]===], friendlyFire = "true", spawnItems = "false", }) -- Spawn players when they join the game Event:addPeerOpenedListener(function(peer) handleSpawnPeer(peer) end) -- Just returns an inventory with 5000 coins function getHumanStartInventory() local inventory = {} table.insert(inventory, { type = "coin", quantity = 5000 }) return inventory end -- Spawns a peer as a human function handleSpawnPeer(peer) local inventory = getHumanStartInventory() spawnPeerWithTimerAndCounter(peer, playerSpawnDelay, "Human", Level:getRandomSpawnPoint("playerSpawn"), "Respawning in" ,function(human) spawnPeerHuman(peer, human) end, inventory) end -- When the player is spawned, add a death respawn listener and let the peer control the human function spawnPeerHuman(peer, human) human:addDeathListener(function() handleSpawnPeer(peer) end) peer:controlEntity(human) end
Lua Reference
It is possible to write your very own gamemodes for your server using Lua.
See the Lua Reference for a list of all the available commands.