How do I make a lottery system?

Get help using Construct 2

Post » Sun Sep 18, 2016 12:19 pm

I want to make a lottery system kind of like in the game Basketball where the player puts in a certain amount of tokens (in my case 1) then the system chooses one random item to give the player.
B
25
S
6
G
4
Posts: 173
Reputation: 3,928


Post » Sun Sep 18, 2016 4:28 pm

Lordshiva1948 wrote:Ayolabi12345 find your answer here

https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0

this link does not work.
B
25
S
6
G
4
Posts: 173
Reputation: 3,928

Post » Sun Sep 18, 2016 4:29 pm

Lordshiva1948 wrote:Ayolabi12345 find your answer here

https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0

this link does not work.
B
25
S
6
G
4
Posts: 173
Reputation: 3,928

Post » Mon Sep 19, 2016 12:57 am

This is one way to do it:
Add an instance variable to the items you will use as price.
Each item has a different Integer value starting at zero (e.g. t-shirt=0, baseball cap=1, shoes=2, etc.)
When the player inserts the token to play lottery use floor(random(n)) where n is the largest index
do a for each loop for the prize item and pick the item whose instance variable matches the one chosen by floor(random(n)).
B
28
S
10
G
10
Posts: 96
Reputation: 6,582


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests