a question relateing to the hash table object.

For questions about using Classic.

Post » Tue Aug 31, 2010 2:19 pm

i am making a game similar to guitar hero. the notes are stored in external files (hash tables). currently i have 2 applications. an encoder and a decoder. the game works around a simple time mechanism.
every 100 milliseconds add 1 to global var 'time'

that is basically what i did for the timer. here is how i want the program to work. i want to store the note as a vale in the hash table. i want the keys to be named as the current 'time' variable.
unfortunately i cannot figure out how to name a key after a variable. however construct wont let me do the following : & global('time')
this is under key name.

here is the real problem, if i cant have the keys automatically named and recalled from a simple string my encoding and decoding system will not work....
does anyone have any ideas.....
B
2
G
3
Posts: 13
Reputation: 876

Post » Tue Aug 31, 2010 5:11 pm

why &global('timer')
why not just global('timer')
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Wed Sep 01, 2010 1:54 pm

if i type in global('timer') nothing happens :(
as in it accepts the code but when i run it in debug the key doesn't get created... there has got to be a way to do it though.
B
2
G
3
Posts: 13
Reputation: 876

Post » Wed Sep 01, 2010 8:12 pm

sorry, try:
""&global('timer')
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Thu Sep 02, 2010 1:03 am

you rock!! it works! now i should be able to finnish the beta by the end of the week :)
i guess i was putting a space between & and global('timer') or some thing like that. (but why does it usually accept that?) but none the less thank you very much!
B
2
G
3
Posts: 13
Reputation: 876

Post » Thu Sep 02, 2010 6:44 am

same as str(global('timer')) ?
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Thu Sep 02, 2010 9:01 am

[quote="madster":wxapejps]same as str(global('timer')) ?[/quote:wxapejps]

Yes, if you want to insert a key you have to specify the key name as string if it isn't already. Unfortunately it doesn't work automatically with the hash table.

This is especially annoying when you want to add keys and values dynamically from an INI for example. You have to tell the hash if it's a value, string or float. Otherwise it will remain 0.

This is one of the major quirks I see with hash tables, which are otherwise very useful. Unless I'm overlooking something obvious or there's a good reason it works the way it does... at least I can't think of one. :P
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest