The 'Function()' screen action doesn't prevent screen prediction from running the function code.
I have a difficulty setting screen which looks like this:
Code: Select all
screen set_diff(diff_settings):
vbox spacing 6 box_wrap True:
$ y = len(diff_settings)
grid 2 y:
for ds in diff_settings:
textbutton diff_setting_name[ds] + ": " + percentage_description(game.get_diff_setting(ds), False) text_color c_brown background None text_size 18 action NullAction() tooltip diff_setting_description[ds]
hbox: # The player can push those buttons to change difficulty and activate 'custom' difficulty
textbutton "-" text_size 18 action Function(game.change_diff_setting, ds, -0.05)
textbutton "+" text_size 18 action Function(game.change_diff_setting, ds, 0.05)Code: Select all
class Game():
[...]
def change_diff_setting(self, setting, chg):
self.diff = "custom"
if self.diff_settings[setting] + chg > 0:
self.diff_settings[setting] += chg
self.update_achievements()
def update_achievements(self):
self.achievements = True
# Disables achievements if difficulty settings are not at least equal to easy mode.
for k, v in self.diff_settings.items():
if v > diff_dict["easy"][k]: # Higher value = easier difficulty
self.achievements = False
breakNow as far as I understand, 'game.change_diff_setting' should be excluded from screen prediction because it is called with the Function() action, but this is not what happens. Achievements are disabled before the player actually clicks the button to change the difficulty.
I know screen prediction is messing with this because adding a simple 'renpy.notify("bla bla bla")' to the 'update_achievements' method makes the notification loop constantly. However, that behavior is not consistent (on the first try the screen works as intended), so setting a simple offset doesn't work either.
Am I misunderstanding what the screen action 'Function()' does? Is it because I'm calling a class method, or because the methods are nested?
Any hint would be appreciated. Thank you!