If you don't want that to happen; for instance, if you want to keep the player from savescumming an RPG scene or minigame - then use the code below.
It changes how renpy.random behaves slightly. Your Ren'Py game will continually save the internal state of the random engine as a game variable, so that it can survive a save/load cycle.
Edit: Made an update to include the seed() function.
Code: Select all
# options.rpy is a good place for this code
init python:
_oldrandom = renpy.random.random
_oldseed = renpy.random.seed
renpy.random.seed(0)
_globalrandstate = renpy.random.getstate()
def _newrandom():
global _globalrandstate
renpy.random.setstate(_globalrandstate)
rv = _oldrandom()
_globalrandstate = renpy.random.getstate()
return rv
def _newseed(value):
global _globalrandstate
renpy.random.setstate(_globalrandstate)
_oldseed(value)
_globalrandstate = renpy.random.getstate()
renpy.random.random = _newrandom
renpy.random.seed = _newseed
