Issue with a randomly state

Get help using Construct 2

Post » Sun Jan 20, 2013 6:28 pm

Hello everyone,

I am currently testing a prototype board game. But I have a problem with an Instance variable (water.drop) that I would like to load it on start of layout, randomly initializing between 3 states possible (0, 1 or 2). But it doesn't work. And I don't know where it comes from.
When i run the game all the drops of water are in the same state (0).

Here my prototype file:

https://dl.dropbox.com/s/szoyxxnm0iinl13/ProtoWaterDrop.capx?dl=1

Hope you can help me out!

Thanks

Aktarus

ps: I don't speak English very well, so sorry!

B
9
S
1
Posts: 20
Reputation: 1,242

Post » Sun Jan 20, 2013 8:18 pm

There are some plugin dependencies in the capx so posting screenshot of the troublesome events might be a good idea as well :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sun Jan 20, 2013 8:32 pm

sorry,

http://imageshack.us/f/72/dropp.png/
aktarus2013-01-20 20:33:54
B
9
S
1
Posts: 20
Reputation: 1,242

Post » Sun Jan 20, 2013 8:53 pm

Not 100% sure but I think creating the water with chess plugin does not pick the created instance, unlike creating it with one of the build in functions would.

Solution would be to add event:

Water On Created
     Set drop to floor(random(0..3))

You got fun start for a game there by the way :)vee412013-01-20 20:53:40
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sun Jan 20, 2013 8:58 pm

Very good! And thanks Vee41.

It works very well!
B
9
S
1
Posts: 20
Reputation: 1,242

Post » Mon Jan 21, 2013 4:15 am

Why not use choose(0,1,2,3)

I guess things like floor, int, random would work but choose is the most logical choice (Even though it would do the exact same thing)

Using floor(random(0,3)) actually will (almost) never get you 3. Since it chooses a huge range of decimal points, there's thousands of possibilities between 2 and 3. The likelihood of getting 3 is quite slim so you could use choose() OR you could do round(random())
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Mon Jan 21, 2013 12:36 pm

Yes, you right EncriptedCow.
I use now choose(0,1,2)

Thanks
B
9
S
1
Posts: 20
Reputation: 1,242


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests