playMaker

Author Topic: Hash tables, but a grid?  (Read 2172 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 274
    • View Profile
    • My Video Game Projects Web Site
Hash tables, but a grid?
« on: November 22, 2019, 08:32:36 AM »
Hello. It would be great to have hash tables that have more than one column per key. For example, in my game I have 100 item prefabs, and an icon for each. Currently I must have a giant hash table containing all prefabs, and a second Icon Hash table containing all icons. Now that I'm splitting the prefab hash into 26 hashes, one for each letter, to make it less clunky to alphabetically add new items, it means I might want to do the same for icons, meaning I'll have twice the number of hash tables since each "type" will need its own.

But if I could have one giant grid (honestly like a SQL table that can store item prefabs, sprites, etc.) then my life would be glorious.

I currently use SimpleSQL to retrieve item strings from database files, and it makes my like SO much better, but unfortunately SQL tables are not "in Unity" so they can't contain Prefabs, sprites, etc.

What is the best way to currently handle this? When I said my game has 100 items, I lied. it actually has 400 and counting, and that's just for basic props; each quest will have its own unique puzzles, keys, etc., too. so anything to reduce duplicated storage, would be great.

I've considered using Scriptable Objects for each item to store this info, but that would mean a unique game object or script thing for each of 400 objects, which is way clunkier than having them all in one place. Not to mention that if I later update the Script for the Scriptable Object, I could lose A LOT of data if I do it wrong.

The big problem is, to quickly find Hash Table entries, they must be alphabetical because there is no search function in the hash table proxy thing. And making them alphabetical is a pain because you cannot "insert" new keys at various points, so new items must just be tacked onto the end. If there was a way to solve these problems, possibly by adding a search function to hash table proxies, this all might be less problematic.
« Last Edit: November 22, 2019, 08:50:38 AM by westingtyler »

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 648
    • View Profile
Re: Hash tables, but a grid?
« Reply #1 on: November 22, 2019, 12:53:56 PM »
I think there's a thing called Array Table in the master file of ArrayMaker on Jean's bitbucket or github I think, something to try in some test project. It might allow you to do that, dunno, better ask him.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15468
  • Official Playmaker Support
    • View Profile
Re: Hash tables, but a grid?
« Reply #2 on: November 25, 2019, 01:15:01 AM »
Hi,

 replied on the other thread, you are best using Resources and proper naming conventions.

you can then use sql and reference your prefabs by name inside the sql tables.

Bye,

 Jean

westingtyler

  • Sr. Member
  • ****
  • Posts: 274
    • View Profile
    • My Video Game Projects Web Site
Re: Hash tables, but a grid?
« Reply #3 on: December 07, 2019, 11:15:44 PM »
thanks. is there some special list of proper naming conventions, or is it a project by project thing? if you can point me to the naming conventions you consider proper, I'll  make adjustments because that sounds useful.

Also, is this "resources" thing how I could let players load asset bundles, ie mods?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15468
  • Official Playmaker Support
    • View Profile
Re: Hash tables, but a grid?
« Reply #4 on: December 09, 2019, 09:25:50 AM »
Hi,

 Convention is really up to you to decide. what matters is that your logic expects a certain name for your resources, so when you create resources, respect that naming convention what ever it is.

for example:

[group]_[category]_[size]

and then you may have

groups:

Weapon
Health
Shield

Category

Player
Ennemy

Size

Small
Medium
Big


and then you can have

Weapon_Player_Big
Shield_Ennemy_Small


yes?

Bye,

 Jean