Skip to main content

02 - Properties & types

Shows the friendly types TPScript maps to C++, plus field private for implementation detail.

Full source​

include "CoreMinimal.h"
include "GameFramework/Actor.h"

uclass AExampleProps : AActor meta: api=EXAMPLES_API
{
method public virtual void BeginPlay() override {
Super::BeginPlay();
PrimaryActorTick.bCanEverTick = true;
}

prop public float Damage EditAnywhere BlueprintReadWrite category="Example" default=10.0f
prop public FName WeaponTag EditAnywhere BlueprintReadWrite category="Example" default="Rifle"
prop public FText DisplayText EditAnywhere BlueprintReadWrite category="Example" default=NSLOCTEXT("", "DisplayText", "Hello")
prop public bool bEnabled EditAnywhere BlueprintReadWrite category="Example" default=true
prop public int32 MaxCount EditAnywhere BlueprintReadWrite category="Example" default=5
field private float FrameCounter

method public virtual void Tick(float DeltaTime) override {
Super::Tick(DeltaTime);
FrameCounter += 1.0f;
if (FrameCounter > 100.0f && bEnabled)
{
UE_LOG(LogTemp, Warning, TEXT("reached 100 frames, weapon: %s"), *WeaponTag.ToString());
FrameCounter = 0.0f;
}
}
}

Line by line​

  • prop public float Damage ... default=10.0f - a float.
  • prop public FName WeaponTag ... default="Rifle" - an FName (fast, hashed label).
  • prop public FText DisplayText ... default=NSLOCTEXT(...) - an FText (localized text).
  • prop public bool bEnabled ... default=true - a boolean.
  • prop public int32 MaxCount ... default=5 - an int32.
  • field private float FrameCounter - a private plain field (no UPROPERTY, invisible to the editor and Blueprints). TPScript knows frame here is a float; the explicit float keeps it unambiguous.

What the friendly types map to​

TPScriptC++
floatfloat
FNameFName
FTextFText
boolbool
int32int32

You could also write the friendly forms (number, name, text, count) on a high-level class and get the same C++ types. See Type system.

Behavior​

FrameCounter accumulates every tick; once it passes 100 (and bEnabled is true), it logs the current weapon tag and resets. bEnabled gates the whole check - flip it to false in Blueprint and the log stops.

Next: 03 - Functions & Events.