playMaker

Author Topic: Inventory System/Hash Tables/Arraymaker  (Read 3429 times)

stvbabb

  • Junior Playmaker
  • **
  • Posts: 66
Inventory System/Hash Tables/Arraymaker
« on: June 08, 2018, 02:37:52 AM »
Hello,

I've been working on a inventory system following the MdotStrange course where we're putting objects into a hash table with a shared key, then using array maker to get that key string and their associated value.

The problem is that I can't seem to 'add' to the original value of an object.

For example, if I have a game object of collectible missiles objects that I add first to a hash table with it's;

1. string name
2. int value of 5
3. sprite for the UI

And then pull that data based on the shared key of 'missile' into an Arraymaker proxy, how can I 'add' value to the, I think, Hash Table int value of 5?

Basically, if I collect a missile game object and it's worth 5, how do I then add a value of 5 more to make 10 (and so) when I collect more missiles? I would then display that in the UI, so the player gets 5, 10, 15, etc.

Currently I'm stuck at 5 missiles even if I collect more of them, that original value of 5 from the hash table doesn't get added up.

I will post screen shots I later today.

Thanks,
Steve

stvbabb

  • Junior Playmaker
  • **
  • Posts: 66
Re: Inventory System/Hash Tables/Arraymaker
« Reply #1 on: June 09, 2018, 02:18:43 AM »
Hello,

My current question is;

Are Hash Tables necessary to build an inventory system?

And, I just can't seem to figure out how to add up the value of Hash Table variables.

Again, if I collect one missile worth 5 int, and then collect another missile worth 5 int, I should of course get 10 - but the hash table says at 5.

Maybe I can just do this with an array. Using Hash Tables seems to take me in an odd direction where it's great to use keys and store the data in keys, but I can't seem to then do anything like add to that data once I have it.

I hope this makes sense, a bit.

Thanks,
Steve


stvbabb

  • Junior Playmaker
  • **
  • Posts: 66
Re: Inventory System/Hash Tables/Arraymaker
« Reply #2 on: June 09, 2018, 02:19:59 AM »
Also, is there a basic inventory system sample on the Eco System? I see there are lots of array maker samples, but would a basic inventory system be possible to provide? Or, is there something very similar already and I'm missing it?

Thanks,
Steve

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Inventory System/Hash Tables/Arraymaker
« Reply #3 on: June 09, 2018, 08:06:39 AM »
Hi.
For array , hash table and xml/json you need to get the value and place it in a variable,
Then add or deduct to that variable (in your sample add 5)
Then you need to set that variables value back to the array / hash table / xml/json

For smaller inventories arrays or hash tables are fine, for larger inventories i would suggest using xml/json and datamaker.

I made a tutorial for an inventory system almost a year ago but its a bit of a long video, i am planning to make a new version and make it more flexible that the current one.
But maybe it can still be helpful for you so here is the video :


The sample is included in my playmaker samples Asset
But you can also follow the video and build it yourself of course :)

stvbabb

  • Junior Playmaker
  • **
  • Posts: 66
Re: Inventory System/Hash Tables/Arraymaker
« Reply #4 on: June 10, 2018, 05:59:24 AM »
Hi djaydino,

Thanks for that! I'll keep working at it, but I think I'm just not storing a live int of the int I need, and that is my problem.

I'll take a look at your video for sure. I'll see how it goes, but I might also buy your samples because it looks like there is quite a few things I could learn from.

When you update the inventory system, will you announce it on the forums?

Cheers,
Steve

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Inventory System/Hash Tables/Arraymaker
« Reply #5 on: June 10, 2018, 09:57:35 AM »
Hi.

yes i will :)

In the new version i will probably use xml and datamaker as it has been a while since i made a tutorial for datamaker :)

stvbabb

  • Junior Playmaker
  • **
  • Posts: 66
Re: Inventory System/Hash Tables/Arraymaker
« Reply #6 on: June 10, 2018, 11:37:15 AM »
Hello,

Cool, thanks for that!

But, I'm still really stuck.

I don't understand how to add up values in a hash table using Playmaker.

I'm still not getting this and just about ready to give up on hash tables. They're either too complex, or I'm trying to do something that they don't do, or it's really simple and I don't get it.

So, if I use Hash Table Add to add an int that is worth 5, and I collect another of that same item, one would assume it adds up to 10, but I just can't get it working. It's always at 5.

Thanks,
Steve

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Inventory System/Hash Tables/Arraymaker
« Reply #7 on: June 10, 2018, 04:38:47 PM »
hi.
Hash Table Add is actually to add a new key.

I made a quick video to explain how it works :