How to create a struct based on FTableRowBase?

I’m very new to C++ with UE4. I’ve read this page: Data Driven Gameplay Elements in Unreal Engine | Unreal Engine Documentation But I’m still unclear on how to add a custom FTableRowBase struct to my project.

When I go to File > Add Code To Project, I can’t find the FTableRowBase class in the ‘Choose Parent Class’ list. Is the parent class of a custom DataTable struct supposed to be something else? Do I choose ‘None’?

I chose ‘None’ and here’s what I put in my ‘MyDataTableStruct.h’

#pragma once

/**
 * 
 */

/** Structure that defines an example data table entry */
USTRUCT(BlueprintType)
struct FExampleDataTable : public FTableRowBase
{
    GENERATED_USTRUCT_BODY()
    
public:
    /** Id of the row */
    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Example)
    FName EntryId;
    /** Value01 */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Example)
    int32 Value01;
    /** Value02 */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Example)
    int32 Value02;
    /** Value03 */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Example)
    int32 Value03;
};

I get these errors though:

Clearly I’m doing something terribly wrong.

Related import CSV error
I’m also trying to import a simple CSV to my UE4 project:

Name,ManaCost,Damage,Level
Attack1,10,2.5,4
Attack2,15,4,12
Spell1,8,2,5
Spell2,12,1.25,10
Buff1,12,3,2
Buff2,16,4,9

But I keep getting the error “Too few rows”. I’ve tried saving/re-saving the data in Google Docs, LibreOffice 4.3 Calc, and Excel for Mac 2011, but the error persists.

There’s someone with a similar problem and fix here: CSV Import Too Few Rows - C++ - Unreal Engine Forums

However, their solution to use Excel on Windows or to patch UE4 is pretty drastic for me. Is there an easier way to get the proper line endings for my CSV file?

1 Like

If that’s the code you have saved locally, you’re missing the autogenerated header include. You need #include “MyDataTableStruct.generated.h” right after the #pragma once so it can actually use the GENERATED_USTRUCT_BODY macro.

To fix the line endings you could use a text editor that can convert from mac to windows files. Any advanced text editor should be able to do it, I don’t know mac software very well.