Skip to main content

Mods

A mod is a player's own server code on a grid they own. It is a Rust crate that the platform builds from source and runs for that one grid. The platform's mods page says how to write one. This page is the Unreal side: Get Starter, Build Mod, Deploy Mod, Set Mod Enabled, List Mods, List My Mods, Call Mod, Get Mod Logs and Delete Mod do each step from your game.

What a mod is for​

A mod is the server rules a player puts on their own land. It keeps its own state across restarts, and any player can call it. So players can add mechanics to their plots without your game shipping new code: your game gives the owner a way to install a mod, and gives visitors a way to call it.

Some mechanics a mod can carry:

  • A guestbook or a visitor counter. The mod counts who called it and remembers the last visitor, and the count survives restarts. This page builds one below.
  • A plot that rebuilds or animates its own blocks, such as a windmill that turns or a garden that grows. The mod writes its grid's blocks, for example on a timer. Its writes reach nearby players live, single cells as voxel updates and a whole chunk as one notice; a player who missed one sees it when the chunk is fetched or reloaded.
  • A sign or a shop counter that answers from the plot's own data: what is built there, who is standing there now, or a notice its owner keeps in the mod's state.
  • A puzzle whose solution the server checks. A visitor sends an attempt with Call Mod, the mod compares it with the answer it keeps, and only the mod opens the door by writing the blocks. The answer stays on the platform, so a modified client cannot fake a solve.

A mod reads only its own grid's chunks, voxels and actors, and writes only that grid's blocks. It hears the grid's world events, such as actors moving and voxels changing. It cannot call your app's own server code or other mods, and only players call it. It runs as its owner, so it is not trusted game state like a Server Object: keep HP, inventory and anything a cheat would want in your game's own Server Objects.

A player's land can be a chunk they own through a chunk claim.

What a player needs​

Every call is the signed-in player's own, made with their app token. Building needs the write_server_code permission in the app. Deploying and deleting need the grid and write_server_code on both the player's access tier and the grid. Switching a mod on or off needs the grid and run_server_code on both. Switching on also needs the app's code admission. The default access tier does not grant any of these: your app's developers do. The platform's mods page has the full table.

A call the player is not allowed to make answers Denied, and Message names the missing permission.

The nodes​

They live on the Crowdy Mods subsystem (UCrowdyMods, a Game Instance subsystem), under Crowdy SDK > Mods. Your module needs CrowdyServices in its Build.cs. Each call is latent: On Done or On Failed fires once, on the game thread, never inside the call. Nothing is cached, so each call asks the platform again.

BlueprintC++Does
Get StarterUCrowdyMods::GetStarter(TFunction<void(const FCrowdyModStarter&)> OnDone)The platform's own starter crate: a Name and the Files to hand to Build Mod.
Build ModUCrowdyMods::BuildMod(const FString& CrateName, const TArray<FCrowdyModFile>& Files, OnProgress, OnDone)Builds one crate and waits for it. On Progress fires on each status change, On Done once at the end.
Deploy ModUCrowdyMods::DeployMod(int64 GridId, const FString& Name, const FString& BuildId, OnDone)Puts a successful build on one of the player's grids under a name. A new mod starts switched off.
Set Mod EnabledUCrowdyMods::SetModEnabled(int64 GridId, const FString& Name, bool bEnabled, OnDone)Switches a mod on or off.
List ModsUCrowdyMods::ListMods(int64 GridId, OnDone)Every mod on one grid.
List My ModsUCrowdyMods::ListMyMods(OnDone)The signed-in player's mods on every grid of the app.
Call ModUCrowdyMods::CallMod(int64 GridId, const FString& Name, const FString& Method, const FString& ParamsJson, OnDone)Calls one method of a mod with JSON parameters and answers its reply as JSON.
Get Mod LogsUCrowdyMods::GetModLogs(int64 GridId, const FString& Name, int32 Limit, OnDone)A mod's latest log lines, oldest first, from the last 24 hours. Limit is 1 to 500, or 0 for 100.
Delete ModUCrowdyMods::DeleteMod(int64 GridId, const FString& Name, OnDone)Stops a mod and removes it, with its state and its versions.
Build Client Mod, Deploy Client ModUCrowdyMods::BuildClientMod(...), UCrowdyMods::DeployClientMod(...)The same two steps for a mod's CLIENT half. No run lock, no pinned revision and no Allow Live Modding check.
Run Project, Get Project StatusUCrowdyMods::RunProject(...), UCrowdyMods::GetProjectStatus(...)Build and deploy one revision of a Studio project, and read where each half is. See Studio Dock.

The player must be signed in to the app. Grid ids are 64-bit: keep them as Integer64 in Blueprint and int64 in C++. Every build, deploy and read (Build Mod, Deploy Mod, Set Mod Enabled, List Mods, List My Mods and the Studio calls) needs Application API v2.73.0; an older one refuses it with GRAPHQL_VALIDATION_FAILED.

Example: a guestbook on a plot​

The guestbook (ALanternGuestbook) stands on a plot its owner claimed. Plot Grid Id is the claimed chunk's grid, Mod Name is the mod's name on it, a sphere Trigger notices who walks in, and a Text Render component named Sign shows what the guestbook says. In Blueprint, give your actor an Integer64 variable named PlotGridId and a Text Render component named Sign.

The platform's starter crate is a greeter, which makes it a ready guestbook. Its name is grid-mod, and it has two methods:

  • visit counts one visit, remembers the caller, and answers a JSON string: "welcome to grid 7, visitor 3".
  • state answers a JSON object: grid, visits, last_visitor (that player's user id), counts of the world events it heard, and the chunk of the last one.

The starter writes no blocks, so nothing here reloads a chunk.

The owner installs the guestbook once and can switch it off. Visitors sign it, and anyone can read it.

Install the guestbook​

Install from the owner's own menu or button, once. Never build on an overlap: a build takes about half a minute.

Get Starter answers the starter's Name, which becomes the mod's name, and its Files. A crate is a list of files, each a Path and its Content: Cargo.toml, README.md and .rs files under src/, at most 64 files and 2 MB of source. Anything else answers Refused before a request is sent.

Build Mod sends the crate and then reads its status every 2 seconds. It gives up after 11 minutes with Failed. A player has one build at a time. On Progress gives the status as it changes: Queued, Building, then Succeeded or Failed.

caution

A crate that does not compile is not an error. Build Mod ends with Result Success and Status Failed, and Log holds the compiler's output, at most 64 KB with the end kept. Check Status before you deploy.

Deploy Mod takes the Build Id from a successful build. The mod's name is 1 to 48 lowercase letters, digits, - or _; a grid holds at most 8 mods and a player at most 64. Deploying a new version of a running mod restarts it.

Set Mod Enabled with Enabled true switches it on. Since Application API v2.66.0 a switched-on mod starts when a player is in its grid, so nothing needs to start it. A call starts it too, which covers the couple of minutes after a platform update in which a player's arrival may not.

InstallGuestbook asks for the platform's starter and hands it to BuildGuestbook. bBusy lets one install, open or close run at a time, so a second press, or a close during a build, cannot be undone by a late answer.

// LanternGuestbook.h
#include "Subsystem/CrowdyMods.h"

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Lantern")
int64 PlotGridId = 0;

// Visitors' games never run the install, so they call the mod by the name set on the placed actor.
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Lantern")
FString ModName = TEXT("grid-mod");

UFUNCTION(BlueprintCallable, Category = "Lantern")
void InstallGuestbook();

// The owner's install, open and close run one at a time, so a late answer never undoes a newer choice.
bool bBusy = false;

// LanternGuestbook.cpp
void ALanternGuestbook::InstallGuestbook()
{
if (bBusy)
{
return;
}
bBusy = true;
TWeakObjectPtr<ALanternGuestbook> WeakThis(this);
GetGameInstance()->GetSubsystem<UCrowdyMods>()->GetStarter([WeakThis](const FCrowdyModStarter& Starter)
{
ALanternGuestbook* Self = WeakThis.Get();
if (!Self)
{
return;
}
if (Starter.Result != ECrowdyModResult::Success)
{
Self->EndStep(Starter.Message);
return;
}
Self->BuildGuestbook(Starter);
});
}

BuildGuestbook remembers the starter's name, builds its files, and shows each status on the sign. A build that did not succeed shows its compiler output, or the message when the call itself failed, and stops there. EndStep ends every step the same way: it frees the buttons and shows the outcome.

// LanternGuestbook.h
#include "Subsystem/CrowdyMods.h"

// A mod's reply is its owner's text, so the sign shows at most this much of it.
static constexpr int32 MaxSignChars = 200;

void BuildGuestbook(const FCrowdyModStarter& Starter);

// Ends the owner's step: frees the buttons and shows Text on the sign.
void EndStep(const FString& Text);

// LanternGuestbook.cpp
void ALanternGuestbook::BuildGuestbook(const FCrowdyModStarter& Starter)
{
ModName = Starter.Name;
TWeakObjectPtr<ALanternGuestbook> WeakThis(this);
GetGameInstance()->GetSubsystem<UCrowdyMods>()->BuildMod(Starter.Name, Starter.Files,
[WeakThis](const FCrowdyModBuild& Build)
{
ALanternGuestbook* Self = WeakThis.Get();
if (Self)
{
Self->Sign->SetText(FText::Format(INVTEXT("Building: {0}"), UEnum::GetDisplayValueAsText(Build.Status)));
}
},
[WeakThis](const FCrowdyModBuild& Build)
{
ALanternGuestbook* Self = WeakThis.Get();
if (!Self)
{
return;
}
// A crate that does not compile is a successful call with Status Failed, and its log says why.
if (Build.Result != ECrowdyModResult::Success || Build.Status != ECrowdyModBuildStatus::Succeeded)
{
Self->EndStep(Build.Log.IsEmpty() ? Build.Message : Build.Log);
return;
}
Self->DeployGuestbook(Build.BuildId);
});
}

void ALanternGuestbook::EndStep(const FString& Text)
{
bBusy = false;
Sign->SetText(FText::FromString(Text.Left(MaxSignChars)));
}

A successful build is deployed on the plot's grid, then switched on, and the sign invites visitors in. A refused deploy or switch shows the platform's reason, for example a grid the player cannot write server code to.

// LanternGuestbook.h
#include "Subsystem/CrowdyMods.h"

void DeployGuestbook(const FString& BuildId);

void SetGuestbookOpen(bool bOpen);

// LanternGuestbook.cpp
void ALanternGuestbook::DeployGuestbook(const FString& BuildId)
{
TWeakObjectPtr<ALanternGuestbook> WeakThis(this);
GetGameInstance()->GetSubsystem<UCrowdyMods>()->DeployMod(PlotGridId, ModName, BuildId, [WeakThis](const FCrowdyModInfo& Info)
{
ALanternGuestbook* Self = WeakThis.Get();
if (!Self)
{
return;
}
if (Info.Result != ECrowdyModResult::Success)
{
Self->EndStep(Info.Message);
return;
}
Self->SetGuestbookOpen(true);
});
}

void ALanternGuestbook::SetGuestbookOpen(bool bOpen)
{
TWeakObjectPtr<ALanternGuestbook> WeakThis(this);
GetGameInstance()->GetSubsystem<UCrowdyMods>()->SetModEnabled(PlotGridId, ModName, bOpen, [WeakThis, bOpen](const FCrowdyModInfo& Info)
{
ALanternGuestbook* Self = WeakThis.Get();
if (!Self)
{
return;
}
if (Info.Result != ECrowdyModResult::Success)
{
Self->EndStep(Info.Message);
return;
}
Self->EndStep(bOpen ? TEXT("Open: walk in to sign") : TEXT("Closed"));
});
}

Sign it when a visitor walks in​

A visitor's game calls the mod. It never ran the install, so it knows the grid and the name from the placed guestbook: Plot Grid Id, and Mod Name, which is grid-mod for the starter.

Call Mod names the grid, the mod and a method, and sends Params Json as the method's argument; an empty Params Json sends {}. Reply Json holds whatever the method returns, as JSON. A string comes back with its quotes, so read it with a JSON reader before you show it.

A switched-off mod answers Denied, and a deleted one answers Not Found. A mod the app has not admitted stays not running even when it is switched on: list it to see whether it runs.

The overlap signs only for this player's own pawn: in a standalone game an AI controller counts as local too, so it also asks Is Player Controlled. bSigned makes it sign once, so each visitor is counted once, by their own game; a failed call clears it, so the next visit tries again.

// LanternGuestbook.h
virtual void NotifyActorBeginOverlap(AActor* OtherActor) override;

// LanternGuestbook.cpp
#include "GameFramework/Pawn.h"

void ALanternGuestbook::NotifyActorBeginOverlap(AActor* OtherActor)
{
Super::NotifyActorBeginOverlap(OtherActor);
// In a standalone game an AI controller is local too, so ask for this player's own pawn.
const APawn* Pawn = Cast<APawn>(OtherActor);
if (!Pawn || !Pawn->IsLocallyControlled() || !Pawn->IsPlayerControlled())
{
return;
}
SignGuestbook();
}

SignGuestbook calls visit and puts the welcome on the sign. The reply is the plot owner's text, so the sign shows at most MaxSignChars of it. Unreal's JSON reader wants an object or an array at the root, so the string reply is read inside an array. A Denied answer means the guestbook is switched off, by its owner or by billing. Reading JSON needs Json in your module's Build.cs.

// LanternGuestbook.h
#include "Subsystem/CrowdyMods.h"

// A mod's reply is its owner's text, so the sign shows at most this much of it.
static constexpr int32 MaxSignChars = 200;

UFUNCTION(BlueprintCallable, Category = "Lantern")
void SignGuestbook();

// Set once this player has signed, so a visitor is counted once however often they walk in.
bool bSigned = false;

// LanternGuestbook.cpp
#include "Serialization/JsonSerializer.h"

void ALanternGuestbook::SignGuestbook()
{
if (bSigned)
{
return;
}
bSigned = true;
TWeakObjectPtr<ALanternGuestbook> WeakThis(this);
GetGameInstance()->GetSubsystem<UCrowdyMods>()->CallMod(PlotGridId, ModName, TEXT("visit"), TEXT("{}"), [WeakThis](const FCrowdyModCall& Call)
{
ALanternGuestbook* Self = WeakThis.Get();
if (!Self)
{
return;
}
if (Call.Result != ECrowdyModResult::Success)
{
// Not counted, so the next visit tries again.
Self->bSigned = false;
Self->Sign->SetText(Call.Result == ECrowdyModResult::Denied ? INVTEXT("Closed") : FText::FromString(Call.Message.Left(MaxSignChars)));
return;
}
// The reply is a JSON string; Unreal's reader needs an array or object at the root, so wrap it in one.
TArray<TSharedPtr<FJsonValue>> Reply;
FString Welcome;
if (FJsonSerializer::Deserialize(TJsonReaderFactory<>::Create(TEXT("[") + Call.ReplyJson + TEXT("]")), Reply) && Reply.Num() == 1
&& Reply[0]->TryGetString(Welcome))
{
Self->Sign->SetText(FText::FromString(Welcome.Left(MaxSignChars)));
}
});
}

Show the owner who came​

state answers the guestbook's whole state, and anyone may call it. ShowGuestbook reads visits and last_visitor from the object and shows them on the sign. A user id is 64-bit, so the reply is read with its numbers kept as written; read as a double, a large id would lose its last digits.

// LanternGuestbook.h
#include "Subsystem/CrowdyMods.h"

UFUNCTION(BlueprintCallable, Category = "Lantern")
void ShowGuestbook();

// LanternGuestbook.cpp
#include "Serialization/JsonSerializer.h"

void ALanternGuestbook::ShowGuestbook()
{
TWeakObjectPtr<ALanternGuestbook> WeakThis(this);
GetGameInstance()->GetSubsystem<UCrowdyMods>()->CallMod(PlotGridId, ModName, TEXT("state"), TEXT("{}"), [WeakThis](const FCrowdyModCall& Call)
{
ALanternGuestbook* Self = WeakThis.Get();
TSharedPtr<FJsonObject> State;
// Numbers are kept as written, so a 64-bit user id reads back exactly.
if (!Self || Call.Result != ECrowdyModResult::Success
|| !FJsonSerializer::Deserialize(TJsonReaderFactory<>::Create(Call.ReplyJson), State, FJsonSerializer::EFlags::StoreNumbersAsStrings))
{
return;
}
int64 Visits = 0;
int64 LastVisitor = 0;
State->TryGetNumberField(TEXT("visits"), Visits);
State->TryGetNumberField(TEXT("last_visitor"), LastVisitor);
Self->Sign->SetText(FText::FromString(FString::Printf(TEXT("%lld visits; last visitor %lld"), Visits, LastVisitor)));
});
}

In Blueprint, Call Mod with Method state answers the same object as text in Reply Json. Show it as it is, or read it in C++.

Close the guestbook​

Set Mod Enabled with Enabled false switches the mod off. While it is off, a visitor's Call Mod answers Denied, and SignGuestbook above shows the guestbook closed. OpenGuestbook switches it on again. Both wait for an install still running.

// LanternGuestbook.h
#include "Subsystem/CrowdyMods.h"

UFUNCTION(BlueprintCallable, Category = "Lantern")
void CloseGuestbook();

UFUNCTION(BlueprintCallable, Category = "Lantern")
void OpenGuestbook();

// LanternGuestbook.cpp
void ALanternGuestbook::CloseGuestbook()
{
if (bBusy)
{
return;
}
bBusy = true;
SetGuestbookOpen(false);
}

void ALanternGuestbook::OpenGuestbook()
{
if (bBusy)
{
return;
}
bBusy = true;
SetGuestbookOpen(true);
}

In Blueprint, it is one Set Mod Enabled node with PlotGridId, the mod's name and Enabled false.

List mods and read their logs​

List Mods and List My Mods answer Mods, an array of Crowdy Mod. Each has:

FieldIs
Mod Id, Name, Grid Id, Owner User IdWhich mod it is and whose.
Version, DigestThe deployed version, and the SHA-256 of its module in hex.
EnabledIts owner switched it on. It runs only while this holds and it is not blocked.
RunningAn instance of it runs now. A switched-on mod that is not running starts on a player's arrival in its grid or on a call.
Blocked, Blocked ReasonA switch such as billing's has stopped it, whatever Enabled says. The reason says which.
Updated At MsUnix time in milliseconds.
Studio Project Id, Studio RevisionThe Studio project and revision this version was built from. Empty when its build named none, as an install's does.

Get Mod Logs answers Lines: each has At Ms, a Level (0 error, 1 warning, 2 info, 3 debug) and the Text. When a call fails or a mod does not do what you expect, read its logs first.

What each result means​

ResultMeans
SuccessDone. For Build Mod it means the build ran to an end; read Status.
Not Signed InThe player has no app token yet. Nothing was sent.
DeniedA missing permission, a grid that is not the player's, or a billing switch such as an empty wallet or a spend cap. Message names which. A switched-off mod answers Denied to a call.
Not FoundNo such mod, build or grid. A deleted mod answers this to a call.
RefusedAny other refusal: a name that is not allowed, a limit reached, or a crate this SDK rejects before sending.
FailedThe request did not complete, or a build did not finish in 11 minutes.
Bad ReplyThe answer was malformed, so nothing from it is returned.
BusyAnother run for this app is still going, or the platform is already building one for this player: a build the platform refuses for that reason answers Busy. Try again once it ends.
Revision ChangedA Studio project's saved revision or module names are not the ones Run Project was asked for, so nothing was built.
Not BuiltThis SDK version does not carry the call yet, so nothing was sent.

In Blueprint the nodes report a result other than Success on On Failed, with Result and Message.

What a mod costs​

A mod bills its owner's player wallet once their monthly trial is used up, not your app, and an empty wallet or a spend cap switches the owner's mods off, which shows as Blocked (see Who pays for a mod).

Each call is one request, except Build Mod, which is one request to send the crate and one every 2 seconds to read its status.

From C++​

Every callback runs once on the game thread, unless the game instance ends first. UCrowdyMods has fixed limits as constants: MaxFiles (64), MaxSourceBytes (2 MB), BuildPollSeconds (2), BuildLimitSeconds (11 minutes), MaxLogLines (500) and DefaultLogLines (100). The types behind the nodes:

TypeIs
ECrowdyModResultSuccess, NotSignedIn, Denied, NotFound, Refused, Failed, BadReply, Busy, RevisionChanged, NotBuilt. Values are only added at the end.
ECrowdyModBuildStatusQueued, Building, Succeeded, Failed.
FCrowdyModFilePath and Content of one source file.
FCrowdyModStarterResult, Name, Files and Message, and bNotServed (C++ only) when the platform serves no such starter. GetClientStarter(OnDone), C++ only, answers the platform's client half starter the same way.
FCrowdyModBuildResult, BuildId, Status, Log, SdkVersion (the version it compiled against, once it started) and Message.
FCrowdyModOne mod: ModId, GridId, OwnerUserId, Name, Version, Digest, bEnabled, bRunning, bBlocked, BlockedReason, UpdatedAtMs, StudioProjectId and StudioRevision.
FCrowdyModInfoResult, Mod and Message: the answer to deploying and switching.
FCrowdyModListResult, Mods and Message.
FCrowdyModLogs, FCrowdyModLogLineResult, Lines and Message; a line is AtMs, Level and Text.
FCrowdyModDeleteResult, bDeleted and Message.
FCrowdyModCallResult, ReplyJson and Message. ReplyJson is the mod's answer as JSON text, empty unless Result is Success.
UCrowdyGetModStarter, UCrowdyBuildMod, UCrowdyDeployMod, UCrowdySetModEnabled, UCrowdyListMods, UCrowdyListMyMods, UCrowdyGetModLogs, UCrowdyDeleteMod, UCrowdyCallModThe nodes. C++ calls the subsystem instead.
FCrowdyModBuildAsyncResult, FCrowdyModStarterAsyncResult, FCrowdyModInfoAsyncResult, FCrowdyModListAsyncResult, FCrowdyModLogsAsyncResult, FCrowdyModDeleteAsyncResult, FCrowdyModCallAsyncResultThe delegate types of the nodes' pins.