Skip to main content

Classes & members

Classes are where most of your gameplay lives. TPScript has two class styles plus a rich set of member kinds.

High-level classes​

class my_hero extends character meta: api=MYGAME_API
{
edit name: text = "Hero"
internal hp: number = 100.0

component body: capsule

when_begin {
SetActorLocation(FVector(0, 0, 100));

say("hello there");
}
}
  • extends character → inherits ACharacter. Supported bases map to their A/U prefixed forms (actor, pawn, character, controller, player_controller, component, …unknown → AActor).
  • High-level names are snake_case; TPScript converts them to PascalCase and adds the correct prefix (A for actors, U for objects/components, F for structs, I for interfaces; default is U).

High-level member keywords​

KeywordMeaningGenerated
edit <name>[: type] [= default]an editable propertyUPROPERTY(EditAnywhere, BlueprintReadWrite)
visible <name>[: type] [= default]a read-only propertyUPROPERTY(VisibleAnywhere, BlueprintReadOnly)
internal <name>[: type] [= default]a private fieldplain C++ member
component <name>: <type>a subobjectUPROPERTY(VisibleAnywhere) + CreateDefaultSubobject
many <name>: <type>an arrayTArray<type*>
pick <name>: <type>a class refTSubclassOf<type>
soft <name>: <type>a soft asset refTSoftObjectPtr<type>
any <name>: <type>an object pointerTObjectPtr<type>
when_begin { }BeginPlay override
when_tick [dt] { }Tick(float dt) override
when_end { }EndPlay(EEndPlayReason) override
run_from_blueprint foo(...) { }BlueprintCallableUFUNCTION(BlueprintCallable)
blueprint_event foo(...)BlueprintImplementableEvent(no body)
event foo(...) { }BlueprintNativeEventbody→_Implementation
run foo(...) { }plain virtual methodnot BP-exposed
ctor { } / constructor { }constructor body

Example high-level members:

class my_door extends actor meta: api=MYGAME_API
{
edit is_open: bool = false
visible health: number = 100.0
internal last_hit_by: name

run open_door() {
is_open = true;
}

event on_open() {
is_open = true;
}

when_begin {
print "door initialized";
}
}

Low-level classes​

uclass AMyDoor : AActor meta: api=MYGAME_API
{
prop public bool bIsOpen EditAnywhere BlueprintReadWrite category="Door" default=false

method public virtual void BeginPlay() override {
Super::BeginPlay();
}
}
  • The base class is stated directly after the colon.
  • implements IMyInterface - comma-separated for multiple interfaces.

Low-level member keywords​

KeywordMeaningGenerated
propa UPROPERTY with explicit specifiers
fielda plain C++ member (no UPROPERTY)
funca UFUNCTION
methoda plain C++ method (not BP-exposed)
ctorconstructor body
component UType "Name"a subobject - quoted name required
delegate / declarein-class delegate declaration
line "..."verbatim header line
forward ...extra forward-declaration header line
include ...per-class include (emitted in that class's header)
log ...per-class log category

prop property specifiers​

prop public FName WeaponTag EditAnywhere BlueprintReadWrite category="Example" default="Rifle"
prop private float Cooldown EditDefaultsOnly clamp=[0.0f, 10.0f] units="seconds"
prop public bool bReplicated Replicated

Specifiers - edit_anywhere, visible_anywhere, edit_defaults_only, edit_default, visible_default, blueprint_read_only, blueprint_read_write, config, allow_private_access, transient, replicated.

Property extras - category="...", default=..., clamp=[lo,hi], units="...", meta(...), display_name="...".

PascalCase forms are also accepted as passthroughs: VisibleAnywhere, EditAnywhere, EditDefaultsOnly, BlueprintReadOnly, BlueprintReadWrite, Config, Transient, Replicated, and BlueprintAssignable (for multicast delegates).

The meta: keys on classes​

KeyMeaning
api=...the API macro (e.g. MYGAME_API). Must match the module name uppercased.
abstractUCLASS(Abstract)
config="..."UCLASS(config=...)
blueprintable / blueprint_typeUCLASS(Blueprintable)
not_blueprintableUCLASS(NotBlueprintable)
edit_inline_newUCLASS(EditInlineNew)
class_group="..."UCLASS(classGroup=...)

Constructors​

// low-level
uclass AMyActor : AActor meta: api=MYGAME_API
{
ctor {
PrimaryActorTick.bCanEverTick = true;
}
}

// high-level
class my_actor extends actor meta: api=MYGAME_API
{
ctor {
PrimaryActorTick.bCanEverTick = true;
}
}

Visibility​

public, protected, private are honored in member declarations:

prop public int32 VisibleProp EditAnywhere
field private int32 SecretCount
method public void DoThing() { }

Next: Functions, events & delegates.