Coming soon toSteam
Modding docsAPI 1

Example mod · theonaris.examples.host-tools 1.0.0

Host Tools

Multiplayer example. The host can bring every player to them with one button. Players can make the host glow in a colour of their choice, with a light floating above them that only they see.

Download Host Tools (558 KB)
Install: put the .zip (or the unpacked folder) in your mods folder: in the game, Mods → Open folder. Then start the game and allow the permissions.
Runs on both
Multiplayer required
Size 566 KB
Permissions net players players.teleport ui input world audio

A multiplayer example with two sides that trust each other only as much as they should:

You will learnWhere
Splitting a mod into server and client scriptsmod.json → entry
Client asks, server decides: validating a requestnet.send in client.lua, net.handle in server.lua
Moving players (server only)Player:teleport
Telling everyone, and remembering it for late joinersnet.broadcast, net.state
A panel from .uxml + .ussui/host-tools.uxml, ui/host-tools.uss
Key bindings kept as settings, with defaults"type": "key" settings, input.bind
Highlighting a player that only you seePlayer:highlight, Player:clearHighlight
A light that follows a player aroundworld.shape, Object:followPlayer, Object:addLight

Try it

You need two computers with the game (it runs one copy per computer): host on one and join from the other.

  1. Install the mod on the host. Players who join are offered the download automatically, because "network": "required".
  2. Host a game. Join from the second computer and walk somewhere else.
  3. On the host, press F6 or the button. The other player lands next to you, and both hear it.
  4. On the other player, press F9. The host glows in the highlight colour, with a small light above them.

Both keys, the highlight colour, the circle's size and the time between summons are settings declared in mod.json: change their defaults there, or from a script with mod.settings.set. The last two are server settings, so the host's values apply to everyone.

Why the server checks everything

A client script runs on a player's own computer and can be changed by that player. The client therefore only asks (net.send("summon")), and server.lua decides:

net.handle("summon", nil, function(player)
  if not player:isHost() then return false, "Only the host can summon everyone." end
  -- cooldown check, then the teleports
end, { rate = 2 })

The player argument is filled in by the game from the network connection. A client cannot pretend to be someone else. net.handle also caps how often each player may ask (rate, here twice a second), and returning false, reason answers that player on the denied channel, which client.lua shows as a message.

The highlight

Player:highlight(look) takes a colour and draws a soft glow over the player, seen only by the player who asked for it. It also accepts one of your materials, from assets.material, if you want a different look. Player:clearHighlight() removes it again; a player who leaves takes their highlight with them, which is why the script checks isValid() before clearing.

The floating light is an ordinary world object: a small sphere from world.shape, attached to the host with Object:followPlayer and lit with Object:addLight. Changing the colour setting while the highlight is on redraws both.

Files

mod.json
scripts/server.lua           permission checks, cooldown, teleports, replicated counter
scripts/client.lua           panel, keys, highlight, reactions to server messages
ui/host-tools.uxml           panel layout
ui/host-tools.uss            panel styles (variables, hover and disabled states)
sounds/summon.wav, arrive.wav, ping.wav

All files

FileSize
mod.json2 KB
README.md4 KB
scripts/client.lua5 KB
scripts/server.lua2 KB
sounds/arrive.wav172 KB
sounds/ping.wav103 KB
sounds/summon.wav276 KB
ui/host-tools.uss1 KB
ui/host-tools.uxml620 B