Download

Should I use an enum or datatable for an item list?

I noticed there are two paths at least to take, probably more… But Basically I have it setup so that varest gets the player inventory externally but it’s just item ID and quantity. I want to link it to an item database so that in-game you can either see it in your inventory screen, let’s say backpack or can buy more from the shop.

Would it be better to use a CSV to data table setup or go with an enum system for this? Does consideration of localization make a difference here? I haven’t studied that part yet but I’m thinking practically speaking.

I read that data tables are best to avoid because they can complicate and cause issues down the line.

I haven’t used VARest but I haven’t heard of data tables “causing issues down the line”. Look into structs if you haven’t already. I use data tables to hold a set of structs. If you just need to reference an item that an Enum is good. If you need to store that items parameters then a struct+data table may be good for that.

Thanks for that, varest is just a free rest API thing on the unreal marketplace. But as for the inventory – I will probably go with the struct + data table. I just hate how little documentation there is for unreal. Every link that could potentially give me the answer redirects to unreal’s home page and it’s annoying. I’d like to read in-depth what these things do like, how do I do a foreach loop for data tables? How do I get the array index? How do I append, modify, delete (while retaining or re-indexing the data table array), shuffle, etc… So knowing these details would really help at reaching a conclusion but why would unreal just remove their wiki and redirect everything to their home page? It’s pretty absurd.

Sorry for that tangent, I just don’t like asking questions and just reading the documents. lol

Data tables are fine, but still there’s bug when you change the struct later. Your game wont compile in that case, so you need to find every single reference and refresh nodes.
However, using data tables is pretty simple. You can use VaRest to get information about user inventory from external database, and read data from your data table etc. or you can use it locally (save game). Depends on what you want .

Wait, you’re telling me that if i ctrl+shift+s, it won’t refresh all the nodes? This is useful to know, thank you!

It will refresh all the nodes. If you change the struct in your data table your compiler will fail until you find all references and refresh all nodes manually.