Moving Values From an Array to HashTable then back

For questions about using Classic.

Post » Fri Jan 25, 2013 3:56 pm

Yay! another veteran is back helping on this forum. I was confused as to where everybody went.

I didn't help because I just never use hash tables. They just seem like less functional arrays to me..Bartosh2013-01-25 16:58:28
Posts: 249
Reputation: 2,323

Post » Sat Jan 26, 2013 5:50 am

Wow! That's a lot to process.

So I've got it. A HashTable has to have a KEY that is a string, but it doesn't matter whether the value is a string or integer. Thanks for the lucid explanation.

Your example is fantastic. I'd never actually considered storing multiple levels within a map. I think I will probably use that idea eventually, but it's going to wait until I finish the basic version of this (random map generation would be something I'd love to put in later too.)

I have one concern. One of the things I've been quite happy with in this project is the possibility of making a map as big as 1000x1000. I once tried storing all of the paths to texture files in a global variable, and it crashed construct after about 40 of them (they were pretty convoluted to be fair c:\users\documents\dropbox\construct projects... etc..) Anyways, I can't find anything on a hard limit for global variables, would you happen to know what it is?

In the meantime this is much simpler than the method I was using, which took me two new files to figure out and a bunch of messy notes on a pad of paper!

and don't worry, I didn't take offense. Just seems like a lot of work helping out everyone, and I'm eager to be able to do the same.
Posts: 123
Reputation: 1,061

Post » Sun Jan 27, 2013 1:28 pm

I don't know of any limit besides RAM. But I also use globals only sparely. Most of the data is stored in arrays, hashtables and dedicated sprites (invisible ones, that never appear on screen, only their PVs are used). It is much easier to work with and less vulnerable.

1 million values per map? Be careful then to not convert them from the string to the array in only one tick, like in my example. Setting up such a huge array will take minutes, and if you do it in one tick the app is known to the system as "not responding", which might irritate users. Instead, use a routine that shows the progress while only converting a smaller part of the array, until done.
Posts: 1,821
Reputation: 8,279


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest