default_inventory = {
last_equipped = {helmet_id = 1,armor_id = 1,sword_id = 1},
last_inventory = {
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
}
}```
i want to make inventory system. every item contains level, power, name. how can i create data schema like ```lua
local schema = {id=1, power=1, level=1, name="sword"}
``` and use it on table?
#How can i create "data schema"?
17 messages · Page 1 of 1 (latest)
I would not recommend you to plot your data like this, there's a lot of pratice to do yeah but
you have to split your static from dynamic data, basically
last_equipped = {helmet_id = 1,armor_id = 1,sword_id =
is by name dynamic data, if not, then consider renaming to default inventory
and in fact, actually getting it out of there in favour of flat tables
instead of dictionaries
this has to do with data normalization practices which I recommend you read on
An easy-to-follow database normalization tutorial, with lots of examples and a focus on the design process. Explains the "why" and "how" of normalization, and takes you step-by-step through:
- First Normal Form (1NF)
- Second Normal Form (2NF)
- Third Normal Form (3NF), with a side note on Boyce-Codd Normal Form (BCNF)
- Fourth Normal Form (4NF...
for example is great tutorial if you're curious on the topic, this is massive when dealing with relational data like you're doing
that makes it more confusing
did not said otherwise, it's a recomendation after all, not telling he has to do it
the reality tho, data normalization makes your data much more scalable, sure it has trade-offs, like anything
number of tables explode
but you can ensure your data is gonna be there, data's gonna be flat, and not data anomalies
which is huge
and if you have noticed, a shit ton of people come here asking why some piece of data they queried is not "there" or nil, this 100% solves that