Help with Global Variable Selecting

This forum is currently in read-only mode.
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • 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).

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

    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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)