Forest engineer

Hello everybody

I am a student that studies forestry. I downloaded Gdevelop 5 to create a simple turn based, click and point game for my exam.

I did some python and C++ coding 15 years ago with friends. I did the Gdevelop tutorial and have a few things already on the clear.

The problem i have at this moment is, i want a random number between 12 and 25 to appear after a text. in the beginning on every turn.

Ex:" Cubic meter: 13 " Next rutn "Cubic meter: 19 " etc.

If you are interested to help or be part of the project, Send me a message and let us see what we can do :smiley:

To generate a random number you need to use the Random() expression and between the () enter the maximum value.
Random(25) will return a random number in range 0-25
Random(13) + 12 will return a random number in range 12-25 because Random(13) return a number in range 0-13 and because you add 12 to the value returned, it is going to make the range 12-25

You want to store this value inside a variable and to use it in a text, you need to convert the value to a string using the ToString() expression and to access a scene variable you need to use the Variable() expression…

The event should look something like this:

I’m assuming you are using a variable to set the beginning of each turn, so this is what I did in the image. When “beginning_of_turn” is = 1, I generate the random number, assign it to a variable and update the text object, then set the value of “beginning_of_turn” to 0 so the event won’t run any more until the beginning of the next turn (when you set the value back to 1)…

Thank you,

It helped a lot :smiley: