Help with Global Variable Selecting

For questions about using Classic.

Post » Fri Mar 05, 2010 3:19 pm

Okay, I want an object to set something (we'll call it Final) to a value (we'll call a global value) from a global variable, but I need the global variable it using to switch a lot. It would be pulling from DIFFERENT global variables depending on what ANOTHER value (let's call it Overhead) from an Object (we'll call it OVH) told it to. So, instead of setting up an event for each possible value that Overhead is holding, like so:

If Overhead is 1: Set Final to global('1')
If Overhead is 2: Set Final to global('2')
etc.

Instead I want this:
Always: Set Final to global(OVH.Value('Overhead'))

It would be selecting the global variable by choosing by name from the value of Overhead.

The problem is that global(OVH.Value('Overhead')) just gives the error: Parameter 1 of 'global' does not take 'unknown'

It can't call the right global variable by using a name filled in from another expression. This means what I could have done in 1 event might take 1000 events. If this isn't possible, it should be added as a feature since it is INCREDIBLY useful. It can't be that hard either since so many other things can do the same kinds of things (or at least similar).
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Fri Mar 05, 2010 4:24 pm

It looks to me like what you need is a hash table. You should look into that instead of playing matchy-matchy with two separate lists of variables.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Mar 05, 2010 7:23 pm

[quote="deadeye":2bek59ef]It looks to me like what you need is a hash table. You should look into that instead of playing matchy-matchy with two separate lists of variables.[/quote:2bek59ef]
I'm not sure that will make what I'm doing any easier. Can hash tables store text?

Edit: Oh, I see. Hashtable can work a little like another list of global variables. I can use the same method I was using before, but this time I don't get the Parameter error. Thanks!
B
2
S
2
G
2
Posts: 372
Reputation: 1,794


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 12 guests