Few questions regarding Variables

This forum is currently in read-only mode.
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Heya. Thanks for your awesome work on Construct.

    Anyways, so I've been fooling around with it a bit and i was delighted to find Variable system is much easier to understand (compared to other game makers), but it also gave me few questions to ponder about.

    1. Is there any way to create a private variable that is not bound to objects? (so I can use it as a 'trigger' mechanism to sorta mimic A.I.)

    2. Can there be an 'universal' variable that works globally but also privately? (i.e Gold for individual characters and globally working based on a same variable)

    3. Is it possible to create a 'group' of variables that stores different set of variables under 1 variable? (like for instance, strength, stamina and agility variable under the character name "Jake")

    4. Is it also possible to 'compare variable' via event action? (like when 2 characters collide, event condition is met and it triggers action which compares stats of 2 chars then decides who takes more damage)

    I guess that's all for now. Forgive me for my ignorance if answer for these happens to be pretty obvious. I'm new

    Thanks!

  • 1. Do you mean like a global variable? Those can be accessed through the system object on the event sheet editor.

    2. I'm not quite sure what you mean here. Could you explain in a little more detail?

    3. You can't create a group of variables. You could probably suggest it on the feature request board.

    4. Use either the 'Compare Private Variable' event under your objects, or use the 'Compare' event under the System object which lets you compare any two things.

    Hope that helps.

  • Thank you for quick response!

    for 1 & 2, I'll try to explain it a bit more specifically.

    for 1, I was basically thinking of private variables that is not related to any objects in any way or form, but their numbers do exist (though invisible), so I can use these sets of variables to use them as a sort of a 'trigger' mechanism, so I can tell A.I to behave in specific way when it is triggered. Taking for instance, an RPG game where you have specific characters in your party, and for each character you have it turns the trigger on (and off for characters you don't have), and the event sheet will check if those triggers are on, and will play certain events for you accordingly (that is related to the character).

    I guess it can be done using global variable, but without any way to organize the variables in directories, it could get cluttered i think.

    and as for 2, i was thinking in the line of - a strategy game for instance, where many warlords have their own set of private value called 'gold', and each castle also have their own 'gold' private value. so instead of having multiple private values of same concept (and complex event sheet programming that follows for 'transferring' that variable) , i thought it would be handy to have a global variable which each objects can gain or subtract individually, and also works globally when needed. I know it sound a bit fuzzy but I hope i explained it well

    Thanks again!

  • If you want a variable to relate to each instance of an object, then you use an object private variable (for example, each objects health, level, if its been selected, etc). If you want a variable which is global, then you use global variables (for example, time, number of lives, etc)

  • About the groups of variables question: a little known syntax feature is 'arrays'. You can try these out for example by using the 'Add lines' in List Box, and typing {"1", "2"}.

    Unfortunately it doesn't seem you can yet have array variables. If this is added, you can do what you described.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 2. Can there be an 'universal' variable that works globally but also privately? (i.e Gold for individual characters and globally working based on a same variable)

    Maybe you want a private variable on a global object? Under 'Common' properties, you can tick Global. The object won't be destroyed at the end of the layout, and will always be available in all event sheet editors.

  • thank you so much for the replies! will definitely try them.

  • > 2. Can there be an 'universal' variable that works globally but also privately? (i.e Gold for individual characters and globally working based on a same variable)

    >

    Maybe you want a private variable on a global object? Under 'Common' properties, you can tick Global. The object won't be destroyed at the end of the layout, and will always be available in all event sheet editors.

    That's a really cool idea acctually... basically it's a "visual" variable array!

    ~Sol

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