Hash Table Help

For questions about using Classic.

Post » Wed Apr 07, 2010 6:24 pm

I was looking at the Hash table and a little confused how it works. I have done them with code but this looks a little different.

For example how hard is it to make Names and Scores for the top 5 members of a track long jump in inches and keep it sorted?

It is hard in Construct to add a name and have Construct check to see if it is better in the top 5 and resort?

Has anyone make a tutorial on Hash Tables?

Thanks
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Wed Apr 07, 2010 7:52 pm

You might want to go with ini.
[url:3snppv4d]http://sourceforge.net/apps/mediawiki/construct/index.php?title=INI_Object[/url:3snppv4d]

The way its set up should work well with what your doing.

Here you could simply add a group for each player, and have an item name called long jump.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Wed Apr 07, 2010 10:26 pm

[quote="Guyon":3kz7ee6a]I was looking at the Hash table and a little confused how it works. I have done them with code but this looks a little different.[/quote:3kz7ee6a]
Well as the object description states: "Stores values under named keys." There's not much more to it really.

David gives a pretty good practical example here:
[url:3kz7ee6a]http://www.scirra.com/forum/viewtopic.php?f=16&t=2478[/url:3kz7ee6a]
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Thu Apr 08, 2010 12:58 am

@ Newt
Ah I see that works much like the Python hash table. This could work perfectly and I fully understand it. But can you sort by value?

@PixelRebirth
Very cool, in fact REALLY cool. but can that be sorted at all?
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Thu Apr 08, 2010 5:37 am

Yeah you can do what ever sorting method you prefer, but none of the array types will sort for you except listbox, and it sorts alphanumerically low to high.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Sun Apr 11, 2010 4:47 pm

I am still struggling with this. Can anyone make an example?

Scores for the top 5 members of a track long jump in inches. Then let me add a new member with jump and sort it?

Thanks
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Sun Apr 11, 2010 7:49 pm

I don't think that a hash table is the right tool for the job in this case.
Try an array:
example
requires 0.99.84
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Sun Apr 11, 2010 8:22 pm

That seems to work R0J0hound, now to see what you actually did.

This was many more steps then I expected, but thanks for the help you are AMAZING!!!
funny now much simpler this is in python. especially with the automatic sort.F
B
28
S
8
G
8
Posts: 530
Reputation: 7,154


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests