Server-side Scripting
Skyrim Together exposes a variety of functionalities for server-side Lua scripting.

Scripting Introduction

Scripting allows users to create Lua plugins for their Skyrim Together servers, which can introduce functionality that isn't natively available. The scripting API is still very much a WIP, so this page will be updated upon the addition of further functions and events.
In order to create or run a script, it has to be in the scripts folder with the following structure:
1
serverdir\scripts
2
└───mymod <= folder
3
└───mymod.lua <= script file
Copied!
test.lua
2KB
Binary
Script example

Script Events

The framework exposes several script events, which can be registered using addEventHandler(name, handler). Some events may be cancelled by calling cancelEvent(reason), these are marked with a [C] below. The arguments provided to the event handler by each event are indicated between the triangular brackets.

Server Events

    onUpdate Fires every tick (20 ticks/sec on regular tickrate servers, 60 ticks/sec on premium).

Player Events

    onPlayerJoin<player> [C] Fires when a player joins the server.
    onPlayerQuit<playerid,reason> Fires when a player leaves the server.
    onPlayerEnterWorld<player> Fires once a player is done joining the server (i.e. all values and such have been initialized).

Quest Events

    onQuestStart<player,quest> Fires when a quest is started.
    onQuestStage<player,quest> Fires when an active quest progresses onto the next stage.
    onQuestStop<player,questid> Fires when a quest is abandoned or completed.

Script Functions

NPC Functions

    id Returns the unique ID of a given NPC.
    position Returns the position of a given NPC.
    rotation Returns the rotation of a given NPC.
    speed Returns the speed a given NPC is moving at.
    AddComponent(object) Adds a component to a given NPC.

Player Functions

    id Returns the unique ID of a given player.
    mods Returns an array of mods that a given player has.
    ip Returns the public IP of a given player.
    party
    discordid Returns the unique Discord ID of a given player.
    AddComponent(object)
    AddQuest(questid)
    GetQuests()
    RemoveQuest(questid)

Quest Functions

    id
    GetStage()

World Functions

    get()
    npcs
    player
    GetPlayer()
    KickPlayer()

Clock Functions

    get()
    SetTime()
    GetTime()
    GetDate()
    GetTimeScale()
    GetRealTime()
Last modified 7mo ago