- Home /
Inventory using a TXT file... Is it possible?
This is merely theorycrafting, but is it possible? Also, how would it be made ideally? I am very new to programming inventory systems and have not got much experience with Arrays and Lists. Ideally I would like it to have a limited amount of slots, equipping, a dictionary so only that item can be placed in that slot, stacking, consumables, etc... Would it be possible?
Thanks in advance! :D
NOTICE: Seeing as moderators might take this post down as they would normally do with people asking for scripts, this is not a begging post. I am gathering others' experience and opinions on the topic in order to begin working on it myself.
What do you mean with it, like saving an inventory as a .txt file?
Couldn't you do this with json, so define a inventory slot like this:
[ID(The ID of the given item),Amount(The amount of the item in that slot),Slot(The slot that this item is assigned to)]
Possible, and a horrible idea.
PlayerPrefs is where you want to go for simple storage of stuff.
Answer by HarshadK · Dec 31, 2014 at 01:28 PM
It is possible to do it using a TXT file although it will be a lot of headache since first you have create a format to store all your required data in that txt file and then write a parser to parse that data to load and save into the file. This is just a lot of work.
You can try using a pre-defined formats like XML or JSON since they will make your job easier since you just have to figure out how you should fit your data into that format and you have readymade parsers available for these formats.
Suppose you decide to use XML you will have a parent node for your inventories list which will contain all the inventory items as its child nodes with their attributes and values. You can then read the file and load this into a List and use in the game. While saving you can just put your items from List to the file.
Answer by haim96 · Dec 31, 2014 at 03:52 PM
or you can use local database for example this free solution from the asset store:
https://www.assetstore.unity3d.com/en/#!/content/20660
didn't check it my self but it should work.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Performance with 100+ CharacterController's 1 Answer
Multiplayer in Action RPG, best approach? 2 Answers