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→ inheritsACharacter. Supported bases map to theirA/Uprefixed 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 (
Afor actors,Ufor objects/components,Ffor structs,Ifor interfaces; default isU).
High-level member keywords
| Keyword | Meaning | Generated |
|---|---|---|
edit <name>[: type] [= default] | an editable property | UPROPERTY(EditAnywhere, BlueprintReadWrite) |
visible <name>[: type] [= default] | a read-only property | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) |
internal <name>[: type] [= default] | a private field | plain C++ member |
component <name>: <type> | a subobject | UPROPERTY(VisibleAnywhere) + CreateDefaultSubobject |
many <name>: <type> | an array | TArray<type*> |
pick <name>: <type> | a class ref | TSubclassOf<type> |
soft <name>: <type> | a soft asset ref | TSoftObjectPtr<type> |
any <name>: <type> | an object pointer | TObjectPtr<type> |
when_begin { } | BeginPlay override | |
when_tick [dt] { } | Tick(float dt) override | |
when_end { } | EndPlay(EEndPlayReason) override | |
run_from_blueprint foo(...) { } | BlueprintCallable | UFUNCTION(BlueprintCallable) |
blueprint_event foo(...) | BlueprintImplementableEvent | (no body) |
event foo(...) { } | BlueprintNativeEvent | body→_Implementation |
run foo(...) { } | plain virtual method | not 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
| Keyword | Meaning | Generated |
|---|---|---|
prop | a UPROPERTY with explicit specifiers | |
field | a plain C++ member (no UPROPERTY) | |
func | a UFUNCTION | |
method | a plain C++ method (not BP-exposed) | |
ctor | constructor body | |
component UType "Name" | a subobject - quoted name required | |
delegate / declare | in-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
| Key | Meaning |
|---|---|
api=... | the API macro (e.g. MYGAME_API). Must match the module name uppercased. |
abstract | UCLASS(Abstract) |
config="..." | UCLASS(config=...) |
blueprintable / blueprint_type | UCLASS(Blueprintable) |
not_blueprintable | UCLASS(NotBlueprintable) |
edit_inline_new | UCLASS(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() { }