playMaker

Author Topic: Advice wanted - Best way of getting/organizing data [SOLVED]  (Read 1096 times)

MarkD

  • Full Member
  • ***
  • Posts: 113
Advice wanted - Best way of getting/organizing data [SOLVED]
« 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? 
« Last Edit: April 19, 2021, 09:28:03 AM by MarkD »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Advice wanted - Best way of getting/organizing data
« Reply #1 on: April 14, 2021, 08:26:07 AM »
Hi.
For our items in our game, i use xml with Data Maker (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 :





« Last Edit: April 14, 2021, 08:36:03 AM by djaydino »

MarkD

  • Full Member
  • ***
  • Posts: 113
Re: Advice wanted - Best way of getting/organizing data
« Reply #2 on: April 14, 2021, 09:43:01 AM »
Thank you!  I'll give all of these tutorials a go. 

MarkD

  • Full Member
  • ***
  • Posts: 113
Re: Advice wanted - Best way of getting/organizing data [SOLVED]
« Reply #3 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!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Advice wanted - Best way of getting/organizing data [SOLVED]
« Reply #4 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.