[SOLVED] Make a more complex dice (random number generator)?

Get help using Construct 2

Post » Sun Aug 09, 2015 9:29 pm

Hi C2 community!

I'm trying to make a random number generator only using global variables and simple commands, but I'm not able to get anywhere.

The random generator draws 6 fixes numbers (1 to 6, like a dice), but always exclude the last two drawn numbers.

To do this I'm using three variables: current (to storage the current drawn number), var1 and var2 (to storage the mini-game and avoid selecting the same number).

There's the current CAPX with the generator test.

http://s000.tinyupload.com/index.php?fi ... 0298583322

If anyone has a suggestion to make it work properly, I would be very grateful. :D

SOLVED!

Below there is a CAPX example based on R0J0hound suggestion:

http://s000.tinyupload.com/index.php?fi ... 9478675491

There is also another example posted by korbaach, that uses array:

https://app.box.com/s/t4gvdfwdhvp75uijslgkdyznqiex7qag
Last edited by lukezero on Mon Aug 10, 2015 1:33 am, edited 7 times in total.
B
39
S
9
G
3
Posts: 261
Reputation: 4,361

Post » Sun Aug 09, 2015 9:43 pm

I dont really understand what you mean......but hhis could help: https://www.scirra.com/tutorials/1267/r ... rpg-tricks

Dont use the same purpose from this tutorial, just use the same technique.

Hope that help!
B
15
S
4
Posts: 153
Reputation: 1,385

Post » Sun Aug 09, 2015 10:04 pm

fathybasha wrote:I dont really understand what you mean......but hhis could help: https://www.scirra.com/tutorials/1267/r ... rpg-tricks

Dont use the same purpose from this tutorial, just use the same technique.

Hope that help!


Thanks, @fathybasha. I'm using the same principles, but my case is a bit more complex.

To simplify my problem, I thought it best illustrate with numbers, because this is the basic principle adopted.

In my case, the random generator always need to exclude the last two drawn numbers.
B
39
S
9
G
3
Posts: 261
Reputation: 4,361

Post » Sun Aug 09, 2015 10:21 pm

just a thought...

Raffle!.capx
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Sun Aug 09, 2015 10:34 pm

This could work also:

var cur=0
var last1=0
var last2=0

on click
--- set last2 to last1
--- set last1 to cur
------while
------ system compare: (cur=last1)|(cur=last2) = 1
--------- set cur to choose(1,2,3,4,5,6)
B
94
S
33
G
113
Posts: 5,353
Reputation: 73,267

Post » Sun Aug 09, 2015 10:34 pm

korbaach wrote:just a thought...

Raffle!.capx


Thanks for this functional example, @korbaach! :D

I was trying to do it without arrays (more 'cause I don't known yet to handle it), but I believe that this is only possible through the arrays, right?
Last edited by lukezero on Mon Aug 10, 2015 10:35 pm, edited 1 time in total.
B
39
S
9
G
3
Posts: 261
Reputation: 4,361

Post » Sun Aug 09, 2015 10:35 pm

R0J0hound wrote:This could work also:

var cur=0
var last1=0
var last2=0

on click
--- set last2 to last1
--- set last1 to cur
------while
------ system compare: (cur=last1)|(cur=last2) = 1
--------- set cur to choose(1,2,3,4,5,6)


Thanks @R0J0hound! I'll try it here! ^^
B
39
S
9
G
3
Posts: 261
Reputation: 4,361

Post » Sun Aug 09, 2015 10:49 pm

I don't know if proceeded correctly, @R0J0hound, but the CAPX with your instructions not worked. :(

Can you take a look at what's going on?

http://s000.tinyupload.com/index.php?fi ... 1693725547
B
39
S
9
G
3
Posts: 261
Reputation: 4,361

Post » Sun Aug 09, 2015 11:59 pm

The "system compare" needs to be in the same block as the "while". It won't work if it's a sub event.
B
94
S
33
G
113
Posts: 5,353
Reputation: 73,267

Post » Mon Aug 10, 2015 12:07 am

R0J0hound wrote:The "system compare" needs to be in the same block as the "while". It won't work if it's a sub event.


It's alive, @R0J0hound! Thanks dude! :D
B
39
S
9
G
3
Posts: 261
Reputation: 4,361

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests