Exploration and inventory screens - Call/ Jump issues

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
User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Exploration and inventory screens - Call/ Jump issues

#1 Post by Kinmoku »

Hi all,

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:

Code: Select all

# 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:

Code: Select all

            textbutton _("Inventory") action Show("inventory")
Thanks in advance.

Also, is there a way to "reset" the call stack?

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Exploration and inventory screens - Call/ Jump issues

#2 Post by hell_oh_world »

Kinmoku wrote: Thu Aug 29, 2019 12:24 pm Hi all,

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:

Code: Select all

# 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:

Code: Select all

            textbutton _("Inventory") action Show("inventory")
Thanks in advance.

Also, is there a way to "reset" the call stack?
Will these work?

Code: Select all

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.
PS. I haven't tried this though.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Exploration and inventory screens - Call/ Jump issues

#3 Post by Alex »

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.

Also, check this article - https://www.renpy.org/doc/html/screen_optimization.html

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Exploration and inventory screens - Call/ Jump issues

#4 Post by Kinmoku »

hell_oh_world wrote: Thu Aug 29, 2019 2:35 pm Will these work?
CODE: SELECT ALL

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.
PS. I haven't tried this though.
Sadly, this doesn't work. Calling the inventory again cycles through all the other inventory labels. Example:

Code: Select all

# 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"

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Exploration and inventory screens - Call/ Jump issues

#5 Post by Kinmoku »

Hang on... Changing Jump back to Call (in the inventory screen) seems to work. I also added zorder.

Code: Select all

screen inventory:
    modal True
    zorder 2

    frame xalign 0.5 ypos 0.1:
        vbox:
            if len(items) > 0:
                if "memoryphotos" in items:
                    textbutton "Old Photographs" action Call("memoryphotos_inv") ### Changed back

        textbutton "Done" action [Hide("inventory") , Return()]
Everything else stays the same as I originally had it, except for changing "call screen inventory" to "show screen inventory":

Code: Select all

    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:

Code: Select all

textbutton "Old Photographs" action [Hide("inventory"), Call("memoryphotos_inv")]

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Ocelot