playMaker

Author Topic: How to use and store data from a Xml [SOLVED]  (Read 1404 times)

paradiseprime

  • Full Member
  • ***
  • Posts: 105
How to use and store data from a Xml [SOLVED]
« on: January 13, 2021, 03:01:50 AM »
I use an excel spreadsheet for the card information. Things like Name/Effect/Attack Value/Element and then convert it to an XML. I use XML Select Nodes and Xml Get Next Node List Properties to get that info but I dont know where to go from there.

When I tried adding that info to a hash table, it wouldnt go past 4 but worked when I put the info into an array.

As for the information, I can just feed the info from Xml Get Next Node List Properties into the cards to get my results but that doesnt let me randomize my results or anything else and I feel that isnt the right way to do things. How would I be able to use the information freely?
« Last Edit: January 15, 2021, 01:58:07 AM by paradiseprime »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: How to use and store data from a Xml
« Reply #1 on: January 13, 2021, 06:02:32 AM »
Hi.
How are you placing it into the hash table?
Each hashtable needs a unique key (name) , maybe there is a key name issue.

What type of game are you making (Card game / turn based / action / rpg)

Maybe this video can help :


paradiseprime

  • Full Member
  • ***
  • Posts: 105
Re: How to use and store data from a Xml
« Reply #2 on: January 13, 2021, 01:11:58 PM »
Its a card game. I am using Hash Table Add Many to add all my card info to a single hash table. I assume this isnt the right way to go about it?

My XML grabs,  NAME/EFFECT/ATTACK VALUE/ELEMENT, stores those stats in variables then puts them into all into a hash table.

I am currently trying another way using Array List Create to make arrays with the card info and then find them but I still run into the issue where I cant randomize them.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: How to use and store data from a Xml
« Reply #3 on: January 13, 2021, 01:57:19 PM »
Hi.
I think its better to create a hash table per card, and the reference is the card Id.

Then you can use 'Hashtable Get' (card id as reference) and get the data for that card.

Similar to the video on my previous post, but instead of "Category' it would be your card Id.

paradiseprime

  • Full Member
  • ***
  • Posts: 105
Re: How to use and store data from a Xml
« Reply #4 on: January 13, 2021, 03:27:25 PM »
Ahh ok. Funny enough, I just discovered that exact method but using Array Lists instead.

The ID is the name and array lists are created for each card. Do array lists and hash tables function the same way?

Also would this be ok when making 40+ array lists at start?

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: How to use and store data from a Xml
« Reply #5 on: January 14, 2021, 06:05:33 AM »
Why not if you're organized.
I must warn you that mastering the actions to use and extract XML data can be very cryptic at start and will require a mountain sized amount of tests to handle them properly.
It's worth it if you want edit your data outside of Unity at will and share it with other systems, but is certainly not easy to get into at all.
In comparison, using ArrayLists and HashTables is a walk in the park.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: How to use and store data from a Xml
« Reply #6 on: January 14, 2021, 07:25:53 AM »
Hi.
Quote
Do array lists and hash tables function the same way?

Array is a indexed list.

Hashtable uses Keys (names)

When creating a hashtable the list is not always in the same order.

For this case i would prefer using hash tables.
for example if some cards would have different stats (lets stay 'Stun' for example).

You can get a cards hash table and and use 'Hash Table Get Next' Store the name and result.
after that use a string switch and check the name. (NAME/EFFECT/ATTACK VALUE/ELEMENT/STUN)
Then display or setup the value, then loop back to the get next state.

This way you can easily set different stats variations.

when you use array you would be stuck with index 1 NAME, index 2 EFFECT etc.



there should be no issue having a lot of hashtables/arrays.




paradiseprime

  • Full Member
  • ***
  • Posts: 105
Re: How to use and store data from a Xml
« Reply #7 on: January 15, 2021, 01:57:55 AM »
Thank you very much. Finally got it working. Took a few hours of tinkering but it was worth it.

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: How to use and store data from a Xml [SOLVED]
« Reply #8 on: January 17, 2021, 01:36:35 PM »
A little secret here. While manually editing an ArrayList or HashTable by prefilling it allows only one type of element to be put in it, it's actually totally possible to store any variable of any type in the same and single Array or Table when using Playmaker actions.