Skip to main content

Type system

TPScript lets you use friendly shorthand types (high-level) or explicit Unreal C++ types (low-level) interchangeably.

Friendly → C++ map​

TPScriptC++ type
numberfloat
count / integerint32
boolbool
nameFName
textFText
stringFString
vectorFVector
rotatorFRotator
colorFLinearColor
keyFKey
actorAActor
pawnAPawn
characterACharacter
controllerAController
player_controllerAPlayerController
weaponAWeapon

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​

KindExampleC++
Dynamic arraymany enemies: actor (high-level)TArray<AActor*>
Mapprop TMap<FName, int32> ScoresTMap<FName, int32>
Setprop TSet<FName> UnlockedTSet<FName>
Class referencepick projectile: actor / prop TSubclassOf<AActor> ProjTSubclassOf<AActor>
Object pointerany mesh: mesh / prop TObjectPtr<AActor> TargetTObjectPtr<AActor>
Weak pointerprop TWeakObjectPtr<AActor> WeakRefTWeakObjectPtr<AActor>
Soft assetsoft awesome: sound / prop TSoftObjectPtr<USoundBase> SndTSoftObjectPtr<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.