Skip to content

Getting Started

This guide creates a synchronized resource with a server command and a client notification.

Prerequisites

  • Valheim with BepInExPack Valheim installed
  • Valheim Lua Engine 1.4.5 on the server and every connecting client
  • access to BepInEx/plugins/ValheimLua/resources

Version matching

The server validates the engine version during connection. Keep server and client installations on the same release.

Create the resource

Create this directory:

text
BepInEx/plugins/ValheimLua/resources/hello_world/

Add a manifest.lua:

lua
manifest_version '1.0.0'
name 'hello_world'
author 'Your Name'
version '1.0.0'
description 'My first synchronized resource'

server_script 'server.lua'
client_script 'client.lua'

Add server.lua:

lua
RegisterNetEvent('hello:request', function()
  local peerId = source
  local playerName = Player.GetName(peerId) or 'Viking'

  TriggerClientEvent('hello:response', peerId, 'Welcome, ' .. playerName)
end)

Add client.lua:

lua
RegisterNetEvent('hello:response', function(message)
  Player.Notify(0, message, 'TopLeft')
end)

RegisterCommand('hello', function()
  TriggerServerEvent('hello:request')
end, false)

Start it

Add the resource to BepInEx/config/ValheimLua/server.cfg:

ini
ensure hello_world

Start the server and connect with a client that has Valheim Lua Engine installed. Run /hello in the client console.

The server catalog synchronizes the manifest, client script, and declared files before the client VM starts. Server scripts never leave the server.

Next steps

Lua resources for Valheim, built on a server-authoritative runtime.