L
L
Lev Aleksandrov2021-06-06 12:12:02
MySQL
Lev Aleksandrov, 2021-06-06 12:12:02

How to store inventory slots in database (MySQL)?

Hello.
There is an inventory system in the game.
The inventory has fields:
InventorySlot container[48];
float capacity;
floatweight;
That is, the inventory has 48 slots as an array of objects of type InventorySlot, capacity (float) and weight (float).
The InventorySlot object has the following fields: int ItemID, int Amount.
Saving capacity and weight in the database is not a problem. But what about slots (an array of objects)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2021-06-06
@firedragon

The method is not entirely adequate. The best way is to make a many-to-many table and store it there. Another option is a JSON field and store the desired values ​​there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question