- Home /
Simple Dictionary / Hashtag system for Inventory with Unityscript only ?? (no C#)
Ok so I've got a simple puzzler game that I'm working on for my first College project with objects that I can pick up and everything is storing into an array and then I pack that array into a string and store it using PlayerPrefs. Everything is going fine so far but I've put together a simple spreadsheet of possible objects and what's required to use them etc etc. but I've no idea how to implement this in some sort of simple static database that I setup at the start. Would this be a hashtable thing ? I looked up hashtable in the script reference it seems to be a C# only thing (correct me if I'm wrong) - anyway I would just like to be able to check something against this 'database' like if I press the use button and I'm looking at door1, I need it to check the 'Requires' part of the database to see what is necessary to open the door.
I'm sure you get the idea anyway - I've included a stripped down version of the database below.
This is just the first 8 fields and 2 objects, I have a load more but just so it fits on the page and you get the idea I've shortened it.
btw, in this table -1 means infinite
ID # Name Type Requires Removable? Endpoint UsesLeft
1 Door1 door Key1 no null -1
2 Key1 required null no Door1 1
I could use PHP & MySQL (I'm quite comfortable at that) , but I want to make a simple standalone PC game to hand to my lecturer so he can test without too much effort on his part. I'm a bit lost with parsing XML so I'm hoping there's some simple way to implement this ?
Thanks Eric. after a bit of fresh air and a bit of research I did figure some of this out. However the link you sent is very informative. Thanks again!
Answer by TheDavil · May 17, 2011 at 01:15 PM
Ok I'm sorry about this - I think I've figured out the obvious answer. Although relatively tedious, it will do for now while I get to grips with some of the .Net stuff.
For the moment I've setup a simple script called InventoryItem.js -
var ItemType : String;
var Requires : GameObject;
var RemovableAfterUse : boolean;
var EndPoint : GameObject;
var UsesLeft : int;
var Breakable : boolean;
var CanBreakThings :boolean;
var TimeLeft : int;
var Description : String;
var Transformable : boolean;
var Hint : String;
and that script simply holds the info for each object and I just put in all the info manually into each object, and then I address this info using GetComponent - like this:
theHint = theObject.GetComponent ("InventoryItem").Hint;
It will do for now, as it's only a very simple proof-of-concept project. In the meantime I will look into Dictionaries Hashtables etc.
Your answer
Follow this Question
Related Questions
Var names in Unity javascript 2 Answers
Parsing User Input to Send to Database 1 Answer
Custom Editor Window to Create and Store Item Data 1 Answer
How to have Database of Dictionary elements with online images??? 0 Answers
Item Database 3 Answers