How do I make a randomize button?

Get help using Construct 2

Post » Mon Oct 17, 2016 4:56 am

I'm trying to currently generate a number between 8-18 in a text box, but I'm at a loss how to do it. I managed to kind of (?) do it, but the text box displays numbers inconsistently. Sometimes when I press the button, a number is generated, and sometimes when I press the button, the text is completely empty. I don't get what I'm doing wrong.
This is for generating a character DnD-style, if anyone has any tips for that sort of thing.

Image
B
4
S
1
Posts: 3
Reputation: 306

Post » Mon Oct 17, 2016 7:17 am

Hi @Alptraum,

try this: Roll.OnClicked -> Strength.Set text -> str(round(random(8,18)))

hope this helps
Best Regards,
vargazso
B
19
S
4
Posts: 32
Reputation: 1,044

Post » Mon Oct 17, 2016 1:55 pm

I wouldn't update the text box every tick, it's not necessary. Just update the text box whenever you change its value. So put the display text action in the even that randomized the Strength value (make sure it's AFTER any events/actions that modify number. It means a few more actions but IMHO it's less prone to error.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
70
S
19
G
8
Posts: 639
Reputation: 9,674


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 23 guests