Skip to content

For Developrs

Akross edited this page May 19, 2026 · 2 revisions

This page shows how to add new commands, edit existing commands, and extend command functionality.


Registering new commands

  1. The easiest way to do so is by first, creating a context variable in VintageStoryPresence.Common.Presence.PresenceContext
public class PresenceContext
{
    public string MyNewCommand { get; set; }
}
  1. Adding the command to the registrar VintageStoryPresence.Common.Presence.PresenceCommands
public static class PresenceCommands
{
    public static void RegisterDefaults()
    {
        PresenceFunctionRegistry.Register("MyNewCommand",
            context => context.MyNewCommand);
    }
}
  1. Lastly, add the functionality within VintageStoryPresence.Common.Presence.Context.PresenceContextBuilder
public static class PresenceContextBuilder
{
    public static PresenceContext BuildContext(float delta)
    {
        // These should cover the api's that you need for accessing any game or player data
        ICoreAPI? api = PresenceCore.Api;
        ICoreClientAPI? capi = PresenceCore.Capi;
        IWorldAccessor? world = api?.World;

        return new PresenceContext
        {
            /* ... */

            // Remember to add a comma before the last command or after yours
            MyNewCommand = "My new function here!",
        }
    }
}

Clone this wiki locally