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.
I'm struggling to figure out what I've done wrong... My inventory screen doesn't seem to be working properly (it returns to odd places, disappears then reappears). I have tried a few things but it doesn't appear to help. Here's my setup with the photograph item as an example:
# story in script.rpy
call main_explore
# exploration.rpy
label main_explore:
scene treehouse_main
call screen main_search
$ result = _return
if result == "photograph":
$ found.append("photos")
mil "Aww…{w=0.5}Photographs!"
call photo_flashback
tm "I'll take these with me."
$ items.append("memoryphotos")
call screen inventory
# continue exploring until 3 items found, then return to # story
# In screens.rpy...
screen inventory:
frame xalign 0.5 ypos 0.1:
vbox:
if len(items) > 0:
if "memoryphotos" in items:
textbutton "Old Photographs" action Call("memoryphotos_inv") ### I tried Jump which worked for a while until later in the game when I used Return and it finished the game too soon.
textbutton "Done" action [Hide("inventory") , Return()] ### I tried removing the Return, but then the game doesn't continue.
# In inventory.rpy
label memoryphotos_inv:
mil "Hmm."
# looks at photos again. can inspect parts
return ## I want this to go back to the inventory screen
I've never called/ jumped a label from an inventory screen before. I want it to pop up when an item is added (or when inventory is selected from the quick menu), then go away when "Done" is pressed without skipping text or returning to another part of the game.
Here's the inventory button in the quick menu as well:
I'm struggling to figure out what I've done wrong... My inventory screen doesn't seem to be working properly (it returns to odd places, disappears then reappears). I have tried a few things but it doesn't appear to help. Here's my setup with the photograph item as an example:
# story in script.rpy
call main_explore
# exploration.rpy
label main_explore:
scene treehouse_main
call screen main_search
$ result = _return
if result == "photograph":
$ found.append("photos")
mil "Aww…{w=0.5}Photographs!"
call photo_flashback
tm "I'll take these with me."
$ items.append("memoryphotos")
call screen inventory
# continue exploring until 3 items found, then return to # story
# In screens.rpy...
screen inventory:
frame xalign 0.5 ypos 0.1:
vbox:
if len(items) > 0:
if "memoryphotos" in items:
textbutton "Old Photographs" action Call("memoryphotos_inv") ### I tried Jump which worked for a while until later in the game when I used Return and it finished the game too soon.
textbutton "Done" action [Hide("inventory") , Return()] ### I tried removing the Return, but then the game doesn't continue.
# In inventory.rpy
label memoryphotos_inv:
mil "Hmm."
# looks at photos again. can inspect parts
return ## I want this to go back to the inventory screen
I've never called/ jumped a label from an inventory screen before. I want it to pop up when an item is added (or when inventory is selected from the quick menu), then go away when "Done" is pressed without skipping text or returning to another part of the game.
Here's the inventory button in the quick menu as well:
screen inventory:
frame xalign 0.5 ypos 0.1:
vbox:
if len(items) > 0:
if "memoryphotos" in items:
textbutton "Old Photographs" action Jump("memoryphotos_inv") ### Replaced Call() with Jump
textbutton "Done" action [Hide("inventory") , Return()]
# In inventory.rpy
label memoryphotos_inv:
mil "Hmm."
# looks at photos again. can inspect parts
call screen inventory ## Call again the inventory in the label instead of return.
My guess is that the issue is in calling screens. When you call a screen it must return a value. If you want player to just interact with it then just show it. You might need to set modal property to True if you don't want the game to continue while screen is opened.
So, when you showing the screen you can safely hide it or jump of this screen to another label.
# In inventory.rpy
label memoryphotos_inv:
mil "Hmm."
# looks at photos again. can inspect parts
call screen inventory
label personal_inv: ## this comes afterwards
# see it again
mil "Oh god...I can't let anyone see this."
call screen inventory
label speakers_inv: ## this comes after that
tm "Maybe I can use these for something?"
call screen inventory
I really thought it would work, too!
Alex wrote: ↑Thu Aug 29, 2019 5:42 pm
My guess is that the issue is in calling screens. When you call a screen it must return a value. If you want player to just interact with it then just show it. You might need to set modal property to True if you don't want the game to continue while screen is opened.
This all makes sense to me as well, but unfortunately it doesn't work either... Well, it "works", but because the exploration/ imagemap screen is still in use, it flashes the inventory screen, then covers it with the exploration/ imagemap screen again. Also, when I click an item in the inventory, it freezes unless I press "Done" - not a huge problem, but something to consider. FYI I added "modal True"
if result == "photograph":
$ found.append("photos")
mil "Aww…{w=0.5}Photographs!"
call photo_flashback
tm "I'll take these with me."
$ items.append("memoryphotos")
show screen inventory ### Changed this
I will give it a full test now and see if it runs into any issues... but so far, it seems good. The inventory screen MUST be manually dismissed (which I don't like), but I am considering adding something like this to the inventory buttons: