Few questions regarding Variables

New releases and general discussions.

Post » Sun Oct 12, 2008 4:38 am

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!
B
2
G
4
Posts: 17
Reputation: 1,084

Post » Sun Oct 12, 2008 4:59 am

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. :)
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Sun Oct 12, 2008 5:22 am

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 :oops:

Thanks again! :)
B
2
G
4
Posts: 17
Reputation: 1,084

Post » Sun Oct 12, 2008 6:23 am

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)
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Sun Oct 12, 2008 1:45 pm

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.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sun Oct 12, 2008 2:07 pm

[quote="acegi":4zk4nhbo]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)[/quote:4zk4nhbo]
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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sun Oct 12, 2008 4:07 pm

thank you so much for the replies! will definitely try them. :)
B
2
G
4
Posts: 17
Reputation: 1,084

Post » Sun Oct 12, 2008 10:52 pm

[quote="Ashley":la3pzq0e][quote="acegi":la3pzq0e]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)[/quote:la3pzq0e]
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.[/quote:la3pzq0e]

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

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 6 guests