Anyone have a working example of renpy.get_displayable_properties?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Anyone have a working example of renpy.get_displayable_properties?

#1 Post by henvu50 »

Anyone have a working example of renpy.get_displayable_properties?

For the sake of learning, I'm trying to get the displayable properties of the Preferences button on the main menu, but I can't get it to return the dictionary of values.

First I added an id to the Preferences displayable.

Code: Select all

        textbutton _("Preferences"):
            id 'btn_pref'
Then from a function, I'm trying to use get_displayable_properties, but I have no idea what layer the Preferences button is on? I tried all of them, but nothing gets returned.

Code: Select all

init python:
   def function_testing():
      b5a = renpy.get_displayable_properties(screen='main_menu', id='btn_pref', layer='master')
      print b5a 
      b6a = renpy.get_displayable_properties(screen='game_menu', id='btn_pref', layer='master')
      print b6a 
      b7a = renpy.get_displayable_properties(screen='navigation', id='btn_pref', layer='master')
      print b7a 

      c5b = renpy.get_displayable_properties(screen='main_menu', id='btn_pref', layer='transient')
      print c5b 
      c6b = renpy.get_displayable_properties(screen='game_menu', id='btn_pref', layer='transient')
      print c6b 
      c7b = renpy.get_displayable_properties(screen='navigation', id='btn_pref', layer='transient')
      print c7b 

      db5 = renpy.get_displayable_properties(screen='main_menu', id='btn_pref', layer='screens')
      print db5 
      db6 = renpy.get_displayable_properties(screen='game_menu', id='btn_pref', layer='screens')
      print db6
      db7 = renpy.get_displayable_properties(screen='navigation', id='btn_pref', layer='screens')
      print db7 

      eb5 = renpy.get_displayable_properties(screen='main_menu', id='btn_pref', layer='overlay')
      print eb5 
      eb6 = renpy.get_displayable_properties(screen='game_menu', id='btn_pref', layer='overlay')
      print eb6 
      eb7 = renpy.get_displayable_properties(screen='navigation', id='btn_pref', layer='overlay')
      print eb7 
I've tried every combo, none of them work?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2376
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Anyone have a working example of renpy.get_displayable_properties?

#2 Post by Ocelot »

1) get_displayable_properties returns only a specific subset of all properties, and, from what I have seen, only matters for input. use get_displayable instead.
2) You will have to play around with console to learn what is exactly in displayable you get. It might be possible, that the field you want is not contained within displayable you got, but within ints child. Or parent. Heavily styled textbutton can internally be represented by a transform, which wraps another transform, which wraps button, which contains transform, which wraps text. And this relationship can change if you change your screen.
3) by default screens are displayed on layer 'screens'. Technically you do not need to explicitely pass layer, because without it, all layers would be searched. Only time where it matters — if you have same displayable on different layers.
4) However, main menu is weird. It doesn't seems possible to access it directly from the game.
< < insert Rick Cook quote here > >

henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: Anyone have a working example of renpy.get_displayable_properties?

#3 Post by henvu50 »

Ocelot wrote: Fri Jul 30, 2021 6:47 am 1) get_displayable_properties returns only a specific subset of all properties, and, from what I have seen, only matters for input. use get_displayable instead.
2) You will have to play around with console to learn what is exactly in displayable you get. It might be possible, that the field you want is not contained within displayable you got, but within ints child. Or parent. Heavily styled textbutton can internally be represented by a transform, which wraps another transform, which wraps button, which contains transform, which wraps text. And this relationship can change if you change your screen.
3) by default screens are displayed on layer 'screens'. Technically you do not need to explicitely pass layer, because without it, all layers would be searched. Only time where it matters — if you have same displayable on different layers.
Got it! :)
4) However, main menu is weird. It doesn't seems possible to access it directly from the game.
I think since it uses a lot of "use" and transclude, you have to access the displayables from the base screen from which the transclude & use takes place.

After giving the main menu preferences button an id, I was able to access it like this:

Code: Select all

db5 = renpy.get_displayable(screen='main_menu', id='btn_pref', layer='screens')
print db5 #prints the text: Button

Post Reply

Who is online

Users browsing this forum: No registered users