Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: MarkD on April 13, 2021, 11:42:21 PM

Title: Advice wanted - Best way of getting/organizing data [SOLVED]
Post by: MarkD on April 13, 2021, 11:42:21 PM
Hey there everyone,

In my project I have a prefab "Item" which is the basic object used by all of the items the player can pick up and use.  In my game, items are pretty simple but they have several attributes that make them different from one another

Right now I'm making an instance of the item, giving it's attributes manually, and then creating copies of that instance.  That's obviously a brute force method and is going to cause bugs and headaches down the road.

So I'd like to do some sort of data sheet or database that my item spawners will set on a blank item to set it up.  That way I'm changing data in a single place.

Any suggestions on the best way to do that while using Playmaker? 
Title: Re: Advice wanted - Best way of getting/organizing data
Post by: djaydino on April 14, 2021, 08:26:07 AM
Hi.
For our items in our game, i use xml with Data Maker (https://hutonggames.fogbugz.com/default.asp?W1133) (hashtables)

i create the hashtables @ runtime from the xml as xml is slow.
and i use numbers as Id for the items.
that id i set as refence on the hashtable.

here is a sample on how a xml item might look like :

Code: [Select]
  <food itemID="400">
    <!-- General Data -->
    <Stat name="SomeFloatData" type="float">2</Stat>
    <Stat name="SomeIntData" type="int">399</Stat>
    <Stat name="SomeBoolData" type="bool">true</Stat>
    <Stat name="SomeStringData" type="string">Bla Bla Bla</Stat>
    <Stat name="SomeRecourcesPath" type="string">ThisObject/Category/Food/Apple</Stat>
    <!-- End General Data -->
  </food>

i get all the data on the xml as a string, then i check the type with a string switch.
so you are not restricted by the ones i showed above, you can make your own custom types if you need.

Then (if for example a int type) i convert the value to the type i need.

then i use the 'name' as a hashtable key and set the value i need.

here are some videos on using xml :





Title: Re: Advice wanted - Best way of getting/organizing data
Post by: MarkD on April 14, 2021, 09:43:01 AM
Thank you!  I'll give all of these tutorials a go. 
Title: Re: Advice wanted - Best way of getting/organizing data [SOLVED]
Post by: MarkD on April 19, 2021, 09:29:36 AM
Heya Djaydino - I wanted to say thank you for the suggestions and tutorial links.  That was exactly what I needed and I got everything working! 

Super cool having my data all in a nice, organized place.

Thank you!
Title: Re: Advice wanted - Best way of getting/organizing data [SOLVED]
Post by: djaydino on April 19, 2021, 10:51:35 AM
Hi.
Happy to help  8)

Data Maker can be Intimidating to begin with but is indeed very useful :)

In our game we ported all our enemy data to xml, which makes it much easier to tweak and make different versions.