Hi there! I've been reading up a lot on the documentation, searching in reddit and lsf, and as well as checking through other codes for examples, but I don't think I can really grasp the concept of how to use, well... use and id. Does anyone perhaps know a thread or tutorial that can explain these tags more in depth?
For context, I'm trying to completely overhaul the navigation and game menu of my game, and I'm hesitant since it might cause the game to bug out when I'm not completely informed,,,
[Advice Needed] In-depth explanation for "Use" and "id"
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.
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.
- AceQueenKimu24
- Newbie
- Posts: 19
- Joined: Mon May 08, 2017 5:17 am
- Projects: Blooming Romance | Marionette
- Deviantart: 24WildHeart
- itch: 24_wildheart
- Contact:
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Contact:
Re: [Advice Needed] In-depth explanation for "Use" and "id"
- `use` (as based on this: https://www.renpy.org/dev-doc/html/screens.html#use) is a screen statement that enables you to use a predefined screen that you made inside a screen. you can use `use` to recycle screens as well as creating templates for your displayables around the screen.
to use this, create first a screen of your choice. then in your actual screen use `use <screen_name>` to put that screen inside the screen.
be noted that this is a screen we're talking to we can pass stuff around this and use this with `use` statement as well.
you can also use `transclude` which makes using the `use` statement more awesome. and its documented as well in the docs.
- `id` is simply just a property that any displayable can take (buttons, frames, windows, texts, etc.). It uses a string wherein this string can be later referenced using the `renpy.get_widget() and renpy.get_widget_properties()` functions (https://www.renpy.org/doc/html/screen_p ... get_widget). So in other sense, `id` only makes sense if you're planning to use these functions.
to use this, create first a screen of your choice. then in your actual screen use `use <screen_name>` to put that screen inside the screen.
Code: Select all
screen red_square():
frame:
background "#f00"
xysize (100, 100)
screen actual_screen():
use red_square
be noted that this is a screen we're talking to we can pass stuff around this and use this with `use` statement as well.
Code: Select all
screen red_square(**properties):
frame:
properties properties # the properties is documented at the link I sent. it just takes the passed property and apply it into the displayable
screen actual_screen():
use red_square(
background="#f00",
xysize=(50, 50))
Code: Select all
screen red_square(**properties):
frame:
properties properties # the properties is documented at the link I sent. it just takes the passed property and apply it into the displayable
transclude # any child that you'll pass when using the use statement in this screen will be placed inside this frame.
screen actual_screen():
use red_square(
background="#f00",
xysize=(50, 50)): # observe the colon, we can now use the red_square as a container
text "Hello World" # imagine this text replacing the `transclude` in the definition of red_square
- AceQueenKimu24
- Newbie
- Posts: 19
- Joined: Mon May 08, 2017 5:17 am
- Projects: Blooming Romance | Marionette
- Deviantart: 24WildHeart
- itch: 24_wildheart
- Contact:
Re: [Advice Needed] In-depth explanation for "Use" and "id"
That's a little more understandable, thank you! Though if you don't mind me asking, I'd sometimes see use take a parameter and contain a block like this:hell_oh_world wrote: ↑Wed Dec 23, 2020 9:36 pm - `use` (as based on this: https://www.renpy.org/dev-doc/html/screens.html#use) is a screen statement that enables you to use a predefined screen that you made inside a screen. you can use `use` to recycle screens as well as creating templates for your displayables around the screen.
to use this, create first a screen of your choice. then in your actual screen use `use <screen_name>` to put that screen inside the screen.Code: Select all
screen red_square(): frame: background "#f00" xysize (100, 100) screen actual_screen(): use red_square
be noted that this is a screen we're talking to we can pass stuff around this and use this with `use` statement as well.you can also use `transclude` which makes using the `use` statement more awesome. and its documented as well in the docs.Code: Select all
screen red_square(**properties): frame: properties properties # the properties is documented at the link I sent. it just takes the passed property and apply it into the displayable screen actual_screen(): use red_square( background="#f00", xysize=(50, 50))
- `id` is simply just a property that any displayable can take (buttons, frames, windows, texts, etc.). It uses a string wherein this string can be later referenced using the `renpy.get_widget() and renpy.get_widget_properties()` functions (https://www.renpy.org/doc/html/screen_p ... get_widget). So in other sense, `id` only makes sense if you're planning to use these functions.Code: Select all
screen red_square(**properties): frame: properties properties # the properties is documented at the link I sent. it just takes the passed property and apply it into the displayable transclude # any child that you'll pass when using the use statement in this screen will be placed inside this frame. screen actual_screen(): use red_square( background="#f00", xysize=(50, 50)): # observe the colon, we can now use the red_square as a container text "Hello World" # imagine this text replacing the `transclude` in the definition of red_square
Code: Select all
use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=1.0):
##insert code
Re: [Advice Needed] In-depth explanation for "Use" and "id"
Code: Select all
use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=1.0):
##insert code
Code: Select all
frame:
# here somewhere is use navigation
text dont_remember_but_it_where_"History_goes"
if scroll == "vpgrid":
vpgrid:
transclude
elif scroll == "vievport":
viewport:
transclude
else:
transcude
In this case screen history uses game_menu and is inserted in vpgrid, vpgrid scarts at last say statement, text at up left is "History"
- AceQueenKimu24
- Newbie
- Posts: 19
- Joined: Mon May 08, 2017 5:17 am
- Projects: Blooming Romance | Marionette
- Deviantart: 24WildHeart
- itch: 24_wildheart
- Contact:
Re: [Advice Needed] In-depth explanation for "Use" and "id"
OH, so it literally means which configuration to use then? If so, I understand then, thank you for your help! ^^
Who is online
Users browsing this forum: apocolocyntose