Variable tutorial...

Get help using Construct 3!

Post » Fri Sep 08, 2017 7:21 am

Can someone point me towards a tutorial that explains how to implement variables?

I've looked through the manual but the explanation seems pretty light. I need a working example so I can see how set them up within the Construct interface.

Thanks all :)
B
9
S
4
G
4
Posts: 101
Reputation: 3,129

Post » Sat Sep 09, 2017 1:14 pm

OK - if no one can point me towards a tutorial, can you help with the following:

Each time my game loads I want the system to choose a random variable (called result), either 1 or 2.

So my event currently looks like:

System > Every tick > System > Set result to int(random(1,2))

How's this? Does this look right?
B
9
S
4
G
4
Posts: 101
Reputation: 3,129

Post » Sat Sep 09, 2017 1:59 pm

choose(1,2) would be simpler.
Read the manual for random - 2 will never actually be reached. int(random(1,3)) would give you 1 or 2.

https://www.scirra.com/manual/126/system-expressions
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Sat Sep 09, 2017 2:12 pm

Bootfit wrote:OK - if no one can point me towards a tutorial, can you help with the following:

Each time my game loads I want the system to choose a random variable (called result), either 1 or 2.

So my event currently looks like:

System > Every tick > System > Set result to int(random(1,2))

How's this? Does this look right?


Every tick is every frame, so you are setting a new value potentially 60 times per second

If you just want to set it once each time the layout loads, you would be better off with System->On start of layout

And if you need it set only once per game session, have it initially set to 0 when you declare it and add System->Compare variable result = 0 as an extra condition
Find all the Construct 2 games that were on Steam Greenlight here
B
36
S
10
G
7
Posts: 480
Reputation: 7,025

Post » Sun Sep 10, 2017 12:11 pm

Brilliant - thanks for the help. Makes sense :)
B
9
S
4
G
4
Posts: 101
Reputation: 3,129


Return to How do I...?

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests