Serialization
Once you know what you want to save, saving your stuff is fairly trivial. Serialization works like this: You describe the item you want to save, rather than saving every single bit of data.
In an inventory example, you have to consider how you want to save the Inventory. Is it a bunch of slots? We can use a table to represent that, and each slot can be a new entry. What's in the slot? If it's an item, we have to consider how we can describe that item:
- What is the item's unique identifier? What is the item class?
- Was the item randomly generated? What was the seed to generate it?
- Does the item have a level? What level is it?
Save all the details you need, but not the actual item. When you load it again, you can use those details to rebuild all of the items in the inventory.
4 comments
Do you mean you don't how to use datastore or don't know how to save that kind of stuff?
I can probably figure out DataStore, so mostly I just don't know how to save that kind of stuff.
To save this kind of stuff, just save a string full of the items in the inventory, then load it up by looping through the table and giving the players the items
Not sure I totally understand, would you mind giving me an example?