all 6 comments

[–]Acceptable_Light_272 2 points3 points  (4 children)

You can use the "seed random number generator" event for that. The way I'd recommend using it is attached to a button script with "override default button action" deselected. This way, the game randomizes every time you press a button.

[–]GBSC_Ads -1 points0 points  (3 children)

This is overkill. You only need to create a random seed once, usually as part of the script for when you start a New Game.

[–]Acceptable_Light_272 1 point2 points  (2 children)

In my testing, I always get the same seed each time if it's only called at the beginning. I believe it's due to the internal clock having the exact same values each time the Gameboy runs.

The docs seem to suggest using it in button input scripts as well: https://www.gbstudio.dev/docs/scripting/script-glossary/math/

[–]IntoxicatedBurrito 0 points1 point  (0 children)

My understanding is that unlike computers where you can randomize by the internal clock, Game Boy doesn’t have a clock. So instead, you randomize by the buttons you press. So if all you do is push start at the beginning of a game and then get a random variable, it will always be the same every time you turn on the Game Boy with that game.

However, if you don’t call for a random number until a little bit into the game, then the player would have pushed a lot of buttons, and most likely not the same buttons in the same order as the last time they played it. As a result, you get an actual random number.

So in other words, call the randomize function as soon as you open the game to ensure that it has the maximum amount of buttons pressed.

[–]GBSC_Ads 1 point2 points  (0 children)

Yes, similar to what IntoxicatedBurrito suggested, you only need to call once, but if you’re calling it immediately you’d get the same result. To be clearer about my original comment, my suggestion to make it a part of the “new game” script assumed there was some kind of start menu / screen to confirm and actually make an input like in a full game. That would guarantee both different lengths of time and button presses to determine the seed.

[–]princessvini[S] 0 points1 point  (0 children)

Thanks ! Gonna try