Type system
TPScript lets you use friendly shorthand types (high-level) or explicit Unreal C++ types (low-level) interchangeably.
Friendly → C++ map
| TPScript | C++ type |
|---|---|
number | float |
count / integer | int32 |
bool | bool |
name | FName |
text | FText |
string | FString |
vector | FVector |
rotator | FRotator |
color | FLinearColor |
key | FKey |
actor | AActor |
pawn | APawn |
character | ACharacter |
controller | AController |
player_controller | APlayerController |
weapon | AWeapon |
Example high-level types:
class inventory extends actor meta: api=MYGAME_API
{
edit gold: count = 100
edit display_name: text = "Hero"
internal private_score: number
}
Containers
| Kind | Example | C++ |
|---|---|---|
| Dynamic array | many enemies: actor (high-level) | TArray<AActor*> |
| Map | prop TMap<FName, int32> Scores | TMap<FName, int32> |
| Set | prop TSet<FName> Unlocked | TSet<FName> |
| Class reference | pick projectile: actor / prop TSubclassOf<AActor> Proj | TSubclassOf<AActor> |
| Object pointer | any mesh: mesh / prop TObjectPtr<AActor> Target | TObjectPtr<AActor> |
| Weak pointer | prop TWeakObjectPtr<AActor> WeakRef | TWeakObjectPtr<AActor> |
| Soft asset | soft awesome: sound / prop TSoftObjectPtr<USoundBase> Snd | TSoftObjectPtr<USoundBase> |
Low-level container example:
uclass AZombieHorde : AActor meta: api=MYGAME_API
{
prop public TArray<AZombie*> WaveItems EditAnywhere BlueprintReadWrite
prop public TMap<FName, float> SpeedBuffs EditAnywhere BlueprintReadWrite
}
In high-level mode, container template arguments are resolved too:
many enemies: actor // -> TArray<AActor*>
prop TArray<actor> Enemies // -> TArray<AActor*>
Special types
TSubclassOf<X>- a class reference (used to spawn or to pick a class in Blueprint).TSoftObjectPtr<T>- a soft reference to an asset (no hard-load).TWeakObjectPtr<T>- a weak reference that auto-nulls if the target is GC'd.TSoftClassPtr<T>- soft class reference.
Literals
prop public float Damage default=10.0f // float literal
prop public int32 Max default=5 // int literal
prop public bool bOn default=true // bool literal
prop public FName Tag default="Rifle" // string literal -> FName
prop public FText Label default=NSLOCTEXT("", "Label", "Hello")
default= accepts the exact C++ initializer expression you want emitted into the property declaration.
Nullability & pointers
TPScript is pointer-aware at emit time: object types (derived from AActor/UObject) automatically emit as raw pointers unless you use TObjectPtr/TWeakObjectPtr/TSoftObjectPtr explicitly. Arrays of object types emit as TArray<X*>.
Next: Classes & members.