Skip to content

Reference

This page lists the types and global helpers a script reaches for most often. The full .NET base class library (System.*, System.Math, MathF, LINQ, collections) is also available. See the C# documentation.

Two namespaces cover almost everything.

using LuminaSharp; // EntityScript, Entity, Registry, attributes, Physics, Net, Asset, Task, Debug
using Lumina; // FVector3, FQuat, component types (S*), SInputEvent, SCollisionEvent

Scripts compile with implicit usings off, so nothing adds a namespace for you.

The math value types live in Lumina and are blittable mirrors of the engine’s own (FVector3 ↔ C++ FVector3).

FVector3 P = new FVector3(0, 2, 0);
float Y = P.Y; // X, Y, Z fields
FVector3 Sum = FVector3.UnitX + P; // operators: + - * /
float D = FVector3.Distance(P, Sum);
FVector3 Dir = (Sum - P).Normalized();
TypeHighlights
FVector2X, Y; Zero, One; Length, Normalized(); Dot, Distance, Lerp
FVector3X, Y, Z; Zero, One, UnitX/Y/Z; Length, Normalized(); Dot, Cross, Distance, Lerp
FVector4X, Y, Z, W; Zero, One (also used for RGBA colors)
FQuatX, Y, Z, W; Identity; AngleAxis(radians, axis); Rotate(v); * composes

Colors are FVector4 (RGBA, components 0–1), or the Color type in LuminaSharp, which is the same four floats with named constants and an implicit conversion. Scalar helpers (Sin, Clamp, Lerp, Tau) come from System.MathF.

Two engine string types are available to scripts, and they answer different questions.

TypeUse
stringOrdinary text. Stored as an engine FString.
FStringThe same storage, spelled as the engine type. Required inside a container, where a string cannot go.
FNameAn interned name: an id, not text. Cheap to compare and copy, case insensitive.

FString converts to and from string implicitly, so it reads like text wherever you use it.

FString Text = "hello"; // implicit
string Back = Text; // implicit
int Length = Text.Length;

FName is the right type for an identifier you compare a lot, like a slot or a tag. Comparison is an id check, so it never walks the characters.

FName Slot = new FName("Head");
if (Slot == new FName("HEAD")) // true, interning is case insensitive
{
// ...
}
string AsText = Slot.ToString(); // resolves the id back to text
bool Empty = FName.None.IsNone; // the empty name

TVector<T> and THashMap<K, V> mirror the engine’s own containers. As a [Property] they are views over storage the engine owns; see Lists and maps for what T may be and how the Details panel draws them.

TVector<float> Values = Cooldowns;
Values.Add(1.5f);
Values.Insert(0, 0.5f);
Values.RemoveAt(0);
Values.Clear();
int Index = Values.IndexOf(1.5f);
bool Present = Values.Contains(1.5f);
foreach (float V in Values) { }
MemberNotes
Count, Clear(), Add, Insert, RemoveAt, Remove, IndexOf, ContainsThe usual IList<T> surface.
List[i]By reference, so List[i] = value works. Plain-value elements only.
Get(i) / Set(i, value)Works for every element type, including FString and TObjectPtr<T>.
AsSpan()The storage as a Span<T>, for plain-value elements. A mutation invalidates it.
THashMap<int, float> Weights = WeightByTier;
Weights.Set(1, 0.5f); // insert or assign
bool Found = Weights.TryGetValue(1, out float Weight);
bool Has = Weights.ContainsKey(1);
Weights.Remove(1);
foreach (var Pair in Weights) { /* Pair.Key, Pair.Value */ }

A view does not own its storage, so do not hold one past the frame you got it in, and treat any index or enumerator as invalid after you change the container.

A lightweight handle to an entity (the C# mirror of ECS::FEntity).

Entity E = World.GetEntityByName("Player");
if (!E.IsNull) { /* ... */ }
uint Raw = E.Id;

Entity.Null is the empty handle; == / != compare by id.

These static classes are usable from anywhere.

ClassMembers
DebugLog(msg), LogWarning(msg), LogError(msg) (writes to the engine log)
AssetLoad<T>(path), LoadAsync<T>(path, callback), Exists(path)
TaskParallelFor, Run, WaitForAll, WorkerCount (see Parallel Work)
GameTaskDelaySeconds, NextFrame, LoadAsync<T>, awaited on the game thread
ProfilerSample(name) (a using scope), Begin/End, Enabled
TimeDelta, DeltaTime, Now
TraceRay, Sphere, then .Ignore / .IgnoreSelf / .WithMask and .Run() / .RunAll()
SoundPlay, PlayAt, PlayEx, PlayOnBus, StopAll, bus volume and mute
FxPlay, PlayAligned, PlayAttached, Stop, for particle systems
GizmoLine, Sphere, Box, Text, plus Color / Thickness / Duration state
GameWorld, InWorld, OpenLevel(url), Quit(), Instance, GetInstance<T>()

The ambient ones (Time, Trace, Sound, Fx, Gizmo, Game.World) resolve the current world for you and are only valid inside a gameplay callback. See Globals & Helpers.

Debug.Log($"spawned {E}");
CStaticMesh? Mesh = Asset.Load<CStaticMesh>("/Game/Content/Meshes/Crate");
using (Profiler.Sample("Perception"))
{
RunPerception();
}

Entity-script and system OnUpdate are auto-profiled by type name, so per-script timings show up in the editor’s Gameplay Profiler with no extra code; Profiler.Sample is for breaking a hot method into sub-scopes.

Use these as [Property] field types to get an asset picker in the editor, then resolve them in code. They live in Lumina.

The two soft types store a virtual path and resolve when you ask. TObjectPtr<T> is a hard reference: it holds the object itself and keeps it alive, which is what you want for something already loaded, or for an object that has no asset path at all. For when to choose which, see Hard vs soft references.

TypeUse
FSoftObjectPathAn untyped soft reference by path; Exists(), Load<T>(), LoadAsync<T>(cb)
TSoftObjectPtr<T>A typed soft reference; Get(), LoadAsync(cb)
TObjectPtr<T>A typed hard reference to a live object, which keeps it alive; Value
[Property(Tooltip = "Played on pickup")]
public TSoftObjectPtr<CAudioStream> PickupSound;
public override void OnReady()
{
CAudioStream? Sound = PickupSound.Get();
}

World (and a system’s World) exposes the world beyond your entity. Full detail is in The World API; the surface in brief.

  • Subsystems, World.Registry, World.Physics, World.Navigation, World.Perception, World.UI, World.Messages, World.Tags, World.Net, World.Draw, World.Input, World.Camera, World.Audio, World.Timers, World.Animation.
  • Entities, CreateEntity, SpawnPrefab, SpawnProjectile, DuplicateEntity, DestroyEntity, SetLifetime, IsValidEntity, GetEntityByName, FindByTag, FindAllByTag, EntityHasTag, GetNumEntities.
  • Transform, GetEntityLocation / SetEntityLocation, SetEntityRotation, TranslateEntity.
  • Hierarchy, SetParent, DetachFromParent, GetParent, GetRootEntity, AttachEntityToSocket, GetSocketLocation.
  • Time, DeltaTime, ElapsedTime, Paused, TimeDilation.

Declared in LuminaSharp, applied to script members or classes.

AttributeOnEffect
[Property]fieldExposes it in the editor and serializes it. Keys are Category, Tooltip, Name, Min, Max, Units, Color. A field, not a property; see Editable properties.
[Serialize]fieldPersists it without showing it in the inspector.
[Hide]fieldNever serialized or shown.
[Alias("OldName")]field/classA prior name so saved data survives a rename. Repeatable.
[SkipHotReload]field/classResets to default on a C# hot reload instead of carrying the old value.
[Button("Label")]parameterless methodDraws a button in the inspector that calls it on the live instance while playing.
[UpdatePhase]class (on EntityScript)Runs this script’s OnUpdate in EScriptPhase.PrePhysics (default) or PostPhysics. See Entity Systems.
[EntitySystem]class (on EntitySystem)Declares a world system’s Stage and Priority.
[Reads] / [Writes]class (on EntitySystem)Declares the components a system touches, so the scheduler can run non-conflicting systems at once.
[DataTableRow]struct/classPublishes the type as a data table row shape; its [Property] members become the columns of any data table asset that picks it.