Ren'Py Over ride a class definition

frozenfeet

Well-Known Member
Aug 2, 2019
1,248
2,014
I would like to over ride an class definition in Renpy specifically this one:

You don't have permission to view the spoiler content. Log in or register now.
I have an Nvidia card and this definition turns off Nvidia "Threaded optimization" then when the player exits the game it turns it back on. The problem is that it actually sets it to "ON" instead of "AUTO". This option only affects opengl games but I play minecraft and it's performance tanks when it's set to "ON". I mentioned it to Renpy Tom and he said that it can cause videos to hitch and then just blamed Nvidia for it turning to "ON" instead of "AUTO" so he won't do anything about it. I could just turn it off but I swear that it actually stops videos from hitching in Renpy.

The file is under renpy/display/core.py and my only solution so far has been to copy the file remove that defininiton and replace it but I have to do it for every version and I have to replace it for every game I play. I always use the y_outline script so if I could create and over ride it would be much eaiser to put it in that script.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
12,532
20,313
I would like to over ride an class definition in Renpy specifically this one:
Hmm... The problem is that it's called during Ren'Py core initialization phase. So, I'm not sure that it can actually be done in a soft way.

Yet, try this (in a rpy file):
Python:
python early hide:
    import renpy.display.core

    def setup_nvdrsMine( self ):
        [the code you want]
    
    renpy.display.core.Interface.setup_nvdrs = setup_nvdrsMine
Importation are global, so the class will be available with your update wherever the module will be used. This while python early is the lowest level you can works in Ren'Py.
But, as I said, it's used really early in Ren'Py, so I'm not sure that the class haven't been already assigned to an object prior to the moment Ren'Py will proceed the python early blocks.

If the class have been already assigned to an object, then there's nothing you can do except the hard update you're actually doing.