Ren'Py How to NOT parse unsupported property?

Danv

Well-Known Member
Aug 21, 2020
1,545
2,357
428
in the context of universal mods, example - i like to (for variety of reasons) on occasionally use "prefer_screen_to_id True" within "text who:" block in "screen say"
You don't have permission to view the spoiler content. Log in or register now.
problem is - it only exist in renpy version > 7.6, and in older versions it throws exception on launch and doesn't start
if i add simple version check - renpy still parses it as usual and dies...
Python:
if renpy.version_tuple > (7, 6, 0):
    prefer_screen_to_id True
is there a way to completely disable/not to parse property if older version is detected? or other way around - sneak it in if new version is detected? maybe some try/exception or other python shenanigans to go around it?
 

Winterfire

Conversation Conqueror
Respected User
Game Developer
Sep 27, 2018
6,523
9,364
800
Try this:
Python:
init python:
    if renpy.version_tuple >= (8, 0, 0):
        config.prefer_screen_to_id = True
Also, do you really need it? I feel like just checking for the major (6,7,8, ...) would be more than enough, right?
So something like this should probably work better:
Python:
init python:
    if renpy.version_tuple[0] >= 8
        config.prefer_screen_to_id = True
 
  • Like
Reactions: Danv

Danv

Well-Known Member
Aug 21, 2020
1,545
2,357
428
Try this:
Python:
init python:
    if renpy.version_tuple >= (8, 0, 0):
        config.prefer_screen_to_id = True
unfortunately doesn't work - it now successfully skips in older version, but doesn't actually work in this format in new ones
"Exception: config.prefer_screen_to_id is not a known configuration variable."
 

Winterfire

Conversation Conqueror
Respected User
Game Developer
Sep 27, 2018
6,523
9,364
800
Yeah my bad, I used your code without checking. That's screen language, thought it was something else.
I'd keep the check in init, and just put a default variable to either true or false, then check normally.

so

if (customVariable) == true
prefer_screen_to_id True
 

Danv

Well-Known Member
Aug 21, 2020
1,545
2,357
428
Yeah my bad, I used your code without checking. That's screen language, thought it was something else.
I'd keep the check in init, and just put a default variable to either true or false, then check normally.

so

if (customVariable) == true
prefer_screen_to_id True
can you elaborate a bit? i think i'm still lost here

i can't move "prefer_screen_to_id" out of screen - it needs to be inside to work, right? because i've tried using
Python:
init python:
    if persistent.colorOverrideEnable == True:
        prefer_screen_to_id = True
it doesn't produce errors in all versions, but also doesn't actually do anything in new ones

i can't hide it behind "if" either
Python:
...
text who:
    id "who"
    if persistent.colorOverrideEnable == True:
        prefer_screen_to_id True
    color "#FF0000"
still get parsed in older version and throws exception, be it check for variable defaulted to "false" or check for renpy version

edit: putting it on python, but still keeping somewhat inside screen also doesn't work
Python:
screen say(who, what):
    style_prefix "say"
    python:
        if persistent.colorOverrideEnable == True:
            prefer_screen_to_id = True
    ...
looks like it really needs to be inside "text who:" only
 
Last edited:

Winterfire

Conversation Conqueror
Respected User
Game Developer
Sep 27, 2018
6,523
9,364
800
can you elaborate a bit? i think i'm still lost here

i can't move "prefer_screen_to_id" out of screen - it needs to be inside to work, right? because i've tried using
Python:
init python:
    if persistent.colorOverrideEnable == True:
        prefer_screen_to_id = True
it doesn't produce errors in all versions, but also doesn't actually do anything in new ones

i can't hide it behind "if" either
Python:
...
text who:
    id "who"
    if persistent.colorOverrideEnable == True:
        prefer_screen_to_id True
    color "#FF0000"
still get parsed in older version and throws exception, be it check for variable defaulted to "false" or check for renpy version

edit: putting it on python, but still keeping somewhat inside screen also doesn't work
Python:
screen say(who, what):
    style_prefix "say"
    python:
        if persistent.colorOverrideEnable == True:
            prefer_screen_to_id = True
    ...
looks like it really needs to be inside "text who:" only
So, outside of screens, say in versioncheck.rpy you write:

Code:
init python:
    if renpy.version_tuple >= (8, 0, 0):
        versionCompatible = True
Create a default variable somewhere called "versionCompatible" and initialize it to False (or put an else in the conditional and set it to False).

Then, just use that variable inside the screen:

Python:
if versionCompatible:
    prefer_screen_to_id True
I think you need to do this workaround because the initial check needs to be done on init.
If I'm wrong, then something like this would also work:

Python:
screen yourScreen():
    default compatible = renpy.version_tuple >= (8, 0, 0):
    
    if compatible:
        prefer_screen_to_id True
 
  • Like
Reactions: Danv

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
12,934
21,509
1,026
[...] still get parsed in older version and throws exception, [...]
And it will always be parsed...

I don't know where you got the idea that putting a statement/property in an if block could possibly prevent that statement/property to be parsed, but it's absolutely not how parsing works. Every single lines that aren't a comment will be parsed, then when the code will be processed, they will eventually, or not, be processed depending on the condition.

Normally I would point to the use of a custom displayable in place of text, but it wouldn't works in the present case since the "id" is proceeded at screen level and not at statement level. So the only way is to hijack the whole parsing process to make the prefer_screen_to_id property to be available whatever the version of Ren'Py, but proceeded only for the version supporting it.



All this being said, there's absolutely nothing "universal" in the fact to rewrite the "say" screen. There isn't many of them, but there's games that use say arguments, and that would then lost all the features linked to this.
It is (was? haven't played it since so long) by example the case for Summertime Saga each time a character speak a foregin language. The say statement carry the dialog line in that foreign language, while a say argument is used to provide the translation that will also be displayed to the player.
 

Danv

Well-Known Member
Aug 21, 2020
1,545
2,357
428
So, outside of screens, say in versioncheck.rpy you write:

Code:
init python:
    if renpy.version_tuple >= (8, 0, 0):
        versionCompatible = True
Create a default variable somewhere called "versionCompatible" and initialize it to False (or put an else in the conditional and set it to False).

Then, just use that variable inside the screen:

Python:
if versionCompatible:
    prefer_screen_to_id True
I think you need to do this workaround because the initial check needs to be done on init.
If I'm wrong, then something like this would also work:

Python:
screen yourScreen():
    default compatible = renpy.version_tuple >= (8, 0, 0):
   
    if compatible:
        prefer_screen_to_id True
nah, it still parses through everything ignoring all the falsed ifs and points straight to "prefer_screen_to_id"
looks like "if" alone, no matter how convoluted, is just not enough when base property is in question, it will get to it and check for validity anyway
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
3,437
6,604
707
As AnneO said, it's not a good idea to blanket override the say screen anyway even on versions of Renpy that support the new stuff - some games have that screen code customized, and replacing it blindly would break things

Perhaps you could have it explained in a README as a manual step that the user much carry out:
- have separate files for a pre-7.6 version, and post 7.6 version, both with extension NOT ".rpy".
- user should rename the relevant file's extension to rpy
- and tell them to not use if it breaks the game.