DataTableRowHandle to Get Data table row: Only literal data table is supported

Hi,

I’m trying to connect data table ref pin from DataTableRowHandle to Get Data Table Row, like the following picture shows.

But it says “Only literal data table is supported” and I can’t connect the pin.

I tried both UE 4.6.1 and 4.7 preview 6 and the result is the same.

Is there something I did wrong or UE4 just doesn’t support this?

Appreciate any help, thanks. :slight_smile:

Have you tried dragging off of the Break DataTableRowHandle “Data Table” pin and call the “Get Data Table Row” from there?

Yes I tried.
Break DataTableRowHandle showed up but pins still not connected.

The result is like the following pictures

29828-datatable3.png

29829-datatable4.png

Hi CrispyVitamin,

I did a bit more testing. the reason it is giving you this is because the input is looking for the full data table to call from, not just an individual component. The “Break DataTableRowHandle” takes specific data from within a data table and breaks it down into smaller components, instead of keeping the data table intact. If you click the dropdown menu under “Data Table” you should be able to get access to the full Data Tables you have available to you.

Hi ,

Thanks for your detailed reply.
I got a bit more little questions, hope you don’t mind. :slight_smile:

If I can’t connect the pins, why does the action menu shows “Break DataTableRowHandle”? Since it can’t be used here, it seems odd to have that option in the menu.

And the reason I want to connect the pins is because I want to store data table ref as an variable in DataTableRowHandles, and use them when needed.

Is there any chance you might add the feature or something similar so we can dynamically assign data table ref to “Get Data Table Row”?

It would make things much easier when using CSV data tables.

Thanks. :slight_smile:

I am also interested in that answer. I have characters inheriting from each-other and therefore I would simply like to store a reference to their respective data table and do all the logic a single time in the character base class. Seems to me like a pretty common use for a data driven system.

I’ve entered a bug report, UE-11952, to be assessed by the development staff on as I’ve discovered that you cannot promote the data table input to a variable, which may mean that it is an error and not intended functionality.

yes I’ve encountered the same bug while working with it, is there any work around currently ?

Unfortunately at present no, the only solution is to add the data table as a hard value in the node.

Since both Data Tables and Structs are working neatly in 4.8, this feature could use some love. There are clumsy workarounds, of course, usually resulting in unnecessary spaghetti, though.

Any chances for UE-11952 to be reassessed?

What is the workflow for having different character BP referencing their respective data table then? In other words how can I inherit from my base character class where all the logic to access the data in the table is implemented without having to override these methods for each child of that class?

Hi Everynone,

UE-11952 has been closed as by design. The reason this is required is that, when reading data table entries, a literal value is required to determine what rows are available to get. Without the literal, this information cannot be determined.

Hi ,

I just want to make sure I understand what you mean. Are you asking how would a child blueprint access a function that selects a specific datatable row from the parent blueprint without overriding the function in the child blueprint?

Yes. Let me just give you a very simple example to make sure we understand each-other. We have two children of a custom Magician class, Merlin and Gandalf. Magician implements a CastSpell method which will query the spell from a spell table. There is two spell tables, Merlin_Spells and Gandalf_Spells. I want to be able to edit a Spells variable on Merlin pointing the corresponding table the same way I would point to the corresponding skeletal mesh, which, obviously is not the same as Gandalf’s. If the table remains a literal argument like it is now, the only way to have such a system working would be to re-implement CastSpell on each Magician which would suck.

What I would probably do at this point (I haven’t tested this myself with data tables but the logic should work) is set up an enum. In this example, have an enum with one selection being Gandalf and one Merlin. When you spawn the character, depending on which you are set the enum accordingly. Place a switch on enum in front of the data table functionality, so that, when the enum is set in your player character, the data accesses only that information that the enum determines is relevant to that player. So Gandalf_Spells for Gandalf and Merlin_Spells for Merlin. This would halt any need to redo functionality and give you direct control over which values you are attempting to access.

It is not very elegant to have to set both the class and the enum in order to spawn Gandalf. It is also not ideal to have to add some logic in the base class each time there is a new magician. But I suppose that could be an acceptable workaround. I am honestly not sure why they made it impossible to make variables of type DataTable.

In this case you wouldn’t require the enum to spawn per se, you’d use the enum to determine what dataset to access from the parent blueprint. This isn’t a workaround so much as a feasible way to do the task you are looking for. Another would be to put the datatable information on a custom event and call the custom event for Gandalf when the actor==gandalf, or merlin for merlin etc. I figured the enum is significantly more performant and easier to set up than some other options that are available.

Hi,

I’ve found a workaround to this issue.

I found these codes from answer hub a while ago, I can’t find original post though, so I just post it here.

And I’ve made some modifications to it to prevent some crash issue.

Create a C++ blueprint function library and add these codes:

.h

UFUNCTION(BlueprintCallable, Category = "DataTable")
	static FEnemyFireStruct GetRowByName(UDataTable* dataTable, FName pName, bool& result); 

.cpp

FEnemyFireStruct UUBPFuncLib::GetRowByName(UDataTable* dataTable, FName pName, bool& result)
{
	result = true;
	FEnemyFireStruct* data = dataTable->FindRow<FEnemyFireStruct>(pName, "", false);
	if (data == NULL)
	{
		result = false;
		return FEnemyFireStruct();
	}

	return *data;
}

FEnemyFireStruct is my custom struct, you can replace with your own struct.

Then you can create a data table handle in blueprint, assign data table to it.

By using this way you can have multiple child share one common parent with same code base and can still assign different data table value to different child.

This isn’t entirely beautiful because you have to create a new function for each struct you want to use, but this is the only option I found workable currently.

47596-dt1.png

1 Like

What I mean is that in an ideal world, spawning a Gandalf should be enough to have what you want. Spawning a Gandalf plus having to specify which table to use is redundant simply because it is something you will always have to do for Gandalf. I am saying your solution is a workaround because it is discouraging inheritance. Imagine for a second if you had to do the same for specifying the skeletal mesh or any other property of the magician class. Now there is really no reason to have a Gandalf and Merlin class anymore, a single Magician class with an MagicianType enumerator at spawn time is all you need. Sadly, I feel this is not how UE encourages you to work for anything else.