Update Datatable in blueprint

Hey! I try to add new montage to datatable, but it’s not working,(print string is working but datatable not updated) any idea?? Thank you!

You cannot, Data Tables are static, read-only in blueprints.

What you can do, is to add the contents of the Data Table to a struct array (since the DT is already using them), modify it (use Set Members In Struct - currently you’re modifying a copy of the data anyway) and save it in the Save Game Object.

You’ll want to save your games eventually anyway.

1 Like

because i think my game only see the
Datatables for this

You’d need to rewrite some of the logic then. Read from the DT, make it into structs and work with those structs while the game runs. Once you’re ready, save the game game using the same structs.

Good luck!

1 Like

Thank you! and so sorry but, I think i don’t understand your answer >< can you give me an image for your answer please?

Technically what you’re doing now should be working just fine. Is it not? When you print the element [1] after Set Array Elem, what do you get?

And I’ll just add this:

You can expose struct’s components for modification. This does not work great with setting array’s elements, though so the method you’ve got now is preferable.

Alternatively, you could do it like this:

280561-cap2.png

But it kind of depends how the array needs to be updated.

Thank you, when i use the print string, i can see it’s work, but in game it’s not changed because i think my game only see the Datatables for this, not that struct, and because of this its not update.

You can’t write to the DT during runtime but you can re-write the data table using editor scripting. To append to the table you have to read the existing table into a string, append the new row(s) to that string, then write that string to the DT. This can be done in Blueprint.