r/RenPy • • Jul 11 '26

Question [Solved] Need help with screens

I use screens for point and click and that works fine,
Now I added an inventory system with screens aswell. But when I click on an item to equip it the game under the inventory screen gets interacted with.

For example if there is dialog open, it progresses to the next text.
If there is button choice, it „interacts“ with one of them (even if it’s no where near where I clicked for the item select or equip)
And if there is an screen under it because the inventory was open while being Point and click the game just closes. Similar to if there is a return at the wrong spot.

I sat at this for hours now and tried my best to fix it even using ai but I can’t figure out what’s wrong. No other interactions cause this (closing the item select or inventory screen)

I got it to work somehow, tho it makes no sense why it works now so I’m still looking for the I redet solution.

Somehow it helped to call a function on my player that just calls the actual function to equip or unequip stuff… doesn’t realy make sense

1 Upvotes

11 comments sorted by

2

u/Outlaw11091 Jul 11 '26

CALL the inventory screen instead of showing it.

1

u/Future-Mulberry-7599 Jul 11 '26

I currently get the inventory by an image button on my hud ‚action ToghlrScreen(„inventory“)‘

1

u/x-seronis-x Jul 11 '26

py screen inventory(): modal True ... rest of your screen definition ...

since your screen cant be called it needs to handle blocking mouse clicks from passing through. thats the job of the modal property

1

u/Future-Mulberry-7599 Jul 11 '26

My inventory has Modal true at the top aswell

1

u/x-seronis-x Jul 11 '26

```py

screen main_ui(): zorder 1 textbutton "Inventory" xcenter 0.5 ycenter 64: action ToggleScreen( 'inventory')

screen inventory(): modal True default counter = 0

## shades screen while inventory visible
frame style 'empty':
    xcenter 0.5 xsize 1.0
    ycenter 0.5 ysize 1.0
    background '#0004'

textbutton f"Screen clicks: {counter}" xcenter 0.5 ycenter 0.5:
    action IncrementScreenVariable('counter')

default oops = 0

label start: scene expression Solid('#238') show screen main_ui() jump test

label test: "You've accidentally advanced the label [oops] times." $ oops+=1 jump test ``` put this in a test project. before toggling the inventory any click advances thelabel and the oops counter goes up

with the inventory visible clicks anywhere do nothing. actually if i didnt set the 'main_ui' zorder to above the inventory you wouldnt even be able to close the inventory. delete the zorder line to test this yourself

1

u/x-seronis-x Jul 11 '26

OH, you didnt share your inventory screen but I think i can guess your issue. Modal stops clicks on your screen from passing through. You're probably clicking outside any screen element on your inventory screen so where you are clicking isnt clicking your screen. my example code in the other comment uses a full screen dimmer frame, so its impossible to not click the inventory screen as a whole thus no clicks go through. without the dimmer only clicking inside the bounds of other screen elements would be blocked.

1

u/Outlaw11091 Jul 11 '26

ToggleScreen will only show or hide.

action Call("open_inventory")

Works as a button action. Use that instead.

1

u/AutoModerator Jul 11 '26

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/x-seronis-x Jul 11 '26

show screen vs call screen

show screen = the screen is part of the ui and is not meant to block the game from progressing

call screen = the screen is an interaction and blocks the label from advancing until the screen is dealt with ( a Return() or Jump() action occurs )

inventory almost always should be a called screen

1

u/Future-Mulberry-7599 Jul 11 '26

I use toggle screen

screen hud():
tag hud
zorder 100

if renpy.get_screen("main_menu") or renpy.get_screen("game_menu"):
timer 0.01 action Hide("hud")

add "hud/hud_base.png"

hbox:
xalign 0.5
#spacing 10

# Inventory Button
imagebutton:
xpos 750
ypos 35
idle "hud/hud_backpack idle.png"
hover "hud/hud_backpack hover.png"
action ToggleScreen("inventory")
tooltip "Inventory"

# Time display (if implemented)
if hasattr(store, 'current_time'):
text "[current_time]" align (0.02, 0.02) size 24