Ren'Py [solved] conditional screen "definition"

Mattock

Newbie
May 27, 2018
91
79
hello,
this is more a modder than developer question.
I want to "define" a screen, specifically:
Python:
init 11 screen game_menu( title = "" ):# or#screen game_menu( title ):
    tag menu
    use navigation
    label title align ( 0.98, 0.3 ) text_size ( stdTxtSize + smallTxtSize )
    transclude
but only if config.version == "some-game-name", else there should not be "defined" a screen with the name "game_menu".
(The case I need this screen with is RenPy 7.4.8)

1)
I know a ~little~ about renpy.define_screen()...
The label could be done as ui.text() I think, but this screen is being used and want to transclude.
and it want to use another screen itself.
Are there python equivalent for "transclude" and "use"?

2)
I fumbled a bit with defining a screen with a different name, and later on deepcopy it and then change the name in a python-block.
I kinda got this to work, but it's super dirty and e.g. requires me to "delete" the cache/screens.rpyb every init.
I think this is a dead end...any other ideas how I could trick RenPy?

thanks Mattock
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,192
but only if config.version == "some-game-name", else there should not be "defined" a screen with the name "game_menu".
This is not possible. The only thing you can do is to condition the content to show one thing, or another, depending of the condition of your choice:
Python:
screen game_menu( title = "" ):
    tag menu
    if config.version == Whatever:
        use navigation
        label title align ( 0.98, 0.3 ) text_size ( stdTxtSize + smallTxtSize )
        transclude
    else:
        [whatever]
This being said, the "game_menu" screen is a mandatory screen, and like all screens it can only be defined once. Therefore I'm almost sure that it's not what you want to do.


Are there python equivalent for "transclude" and "use"?
No, because used screen where just called function, while transcluding wasn't a possibility with the first version of the screen language.


I fumbled a bit with defining a screen with a different name, and later on deepcopy it and then change the name in a python-block.
I kinda got this to work, but it's super dirty and e.g. requires me to "delete" the cache/screens.rpyb every init.
God, even "super dirty" is a nice way to qualify this.


any other ideas how I could trick RenPy?
Yes.
Screens are stored in the renpy.display.screen.screens dictionary, with the tuple ( screenName, variant) as key. Therefore you can simply replace one screen by another one. But for the change to be visible with a shown screen, you'll need to hide the screen, then show it again, before finally restarting the interaction.
 

Mattock

Newbie
May 27, 2018
91
79
@ renpy.define_screen()
No, because used screen where just called function, while transcluding wasn't a possibility with the first version of the screen language.
thank you for confirmation, I thought as much

Screens are stored in the renpy.display.screen.screens dictionary
(and a defaultdict)______yeah, I started there...and for "normal" screens one can do alot!
(and I'm still using this, tho it too should be considered dirty...not as dirty as my hack with the used screen, but dirty...)
BUT if the screen in question is being used by another screen, the problems start!
as said, I consider this (super mega dirty+++111 and) a dead end


but you tipped me in the right direction with
and like all screens it can only be defined once.
tho obvious, a reminder is always helpful
the game I wanna mod does not have a game_menu-screen, so I can make one at an early init and all other games will "override" my screen, so this, !my specific problem!, is solved

I don't flag the thread as solved(but abandoned) coz like you said
This is not possible.
thank you!

EDIT: typo and [strikethrough]
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,192
BUT if the screen in question is being used by another screen, the problems start!
as said, I consider this (super mega dirty+++111 and) a dead end
A dead end that I use without a single issue, even with embedded screens despite their particularity, in my mods and tools since a bit more than 6 years now. While it's not white as a dove, it's also not dirty since it rely at 100% on Ren'Py internal behavior. Plus it's 100% real time revertible.

This is part of my Super Powered mod:
Python:
screen AONcommon_interface(screen_character_list, show_map=False):
    use REALcommon_interface(screen_character_list, show_map)
    transclude
    use AONplayerCheat
    showif AONmod.coreVar.modCenter.AM08i() is True:
        use AONinstanityAura
This screen hijack, without a single issue, a screen used in 8 different screens. It suffice to switch from the original screen to the tweaked one at init time, and the screen itself embed the original one.


Edit: formatting issue
 
Last edited:
  • Like
Reactions: gojira667

Mattock

Newbie
May 27, 2018
91
79
omfg...it all stemmed from me being somewhat too careful...
NOT working: (deepcopy)
renpy.display.screen.screens[...] = copy.deepcopy( renpy.display.screen... )
(mind you, this DOES work with screens, that are NOT being USEd!)

WORKING: (alias? dict.get-method)
renpy.display.screen.screens[...] = renpy.display.screen...

so, to tag the thread [solved], now a VERY SIMPLIFIED howto:
You don't have permission to view the spoiler content. Log in or register now.

thanks again! I may would have not checked again, if you not insisted (and for this I juggled through all your AONutils.pyo(again after 2021!-))