x


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 ?

more ▼

asked May 17 '11 at 11:41 AM

TheDavil gravatar image

TheDavil
58 8 9 14

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!

May 17 '11 at 01:07 PM TheDavil
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered May 17 '11 at 01:15 PM

TheDavil gravatar image

TheDavil
58 8 9 14

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x232
x224
x57
x54

asked: May 17 '11 at 11:41 AM

Seen: 1686 times

Last Updated: May 17 '11 at 12:00 PM