Escape from dialog possible but shouldn't (screen problem)

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
Ayutac
Regular
Posts: 150
Joined: Thu Oct 18, 2012 2:23 pm
Projects: Pokémon Dating Sim
Organization: A Breeze Of Science
Deviantart: Ubro
Location: Mayence, Germany
Contact:

Escape from dialog possible but shouldn't (screen problem)

#1 Post by Ayutac » Fri Oct 03, 2014 9:39 am

Ayutac wrote:[Problem with nested interactions]
Ayutac wrote:[method in screen problem]

EDIT: Today on the 6.1.'13 was the first time I found a topic of mine with search function and it helped me solving the problem. Prosit!
Until the point I encountered another one in this very context.
So, I'm calling an inventory screen by clicking on a button of the quickmenu, wich is itself within the say screen.

[...]

So basically, how do I create new content and be sure to (automatically) jump back to the old one after I'm finished
And this is giving me problems again.

Basically I want to put the player into an unescapable while-loop (yes, I'm just that evil), but he can escape with escape because he is still in some kind of screen. Code!

Code: Select all

screen quick_menu:

    [...]
    textbutton _("Inventory") action ShowMenu('inventory')

Code: Select all

screen inventory:

    tag menu
    
    window:
        $ count = int(math.ceil(math.sqrt(len(inventory))))
        $ pc = count*count
        grid count count:
            style_group "inventory_menu"
            for i in range(0,len(inventory)):
                [sItemName# generation]
                if inventory[i].hasWithD() and invMode == invToUse:
                    imagebutton:
                        idle sItemName1
                        hover sItemName2
                        action [SetVariable('item', i), SetVariable('mouseOverItem', -1), useItem]
                        hovered SetVariable('mouseOverItem', i)
                elif [other situations]
                else:
                    text Null()
            for i in range(len(inventory), pc):
                text Null()
        
        vbox:
            yalign 0.9
            style "say_vbox"
            python:
                if mouseOverItem > -1:
                    hoveredItemText = inventory[mouseOverItem].Name + (
                        " x" + str(inventory[mouseOverItem].getCarryingD()) ) + (
                        " (stored: " + str(inventory[mouseOverItem].getStoredD()) + ")" )
                else:
                    hoveredItemText = " "
            text "[hoveredItemText]"
            textbutton _("back") action [SetVariable("item",-1),Return]

Code: Select all

init -10 python:
    def useItem(): #needed for proper returning from inventory
        renpy.call('useItemLabel')
        return

Code: Select all

## here is specified what certain items do.
## kwargs needed for proper use of renpy.call
## when adding return anywhere, do not forget to set item = -1
label useItemLabel(**kwargs): 
    #global item
    python:
        renpy.hide_screen('inventory')
    if girl != -1 or inventory[item].hasWithD() != True:
        if girl == -1: ## if not we need to remember the item
            $ item = -1
        return
    python:
        if [uses of many items]
        elif item == ITEM_RECURSIVE_BOX:
            narrator("Are you sure?", interact = False)
            if menu([("Yes", True),("No", False)]) == True:
                narrator("Very, very sure?", interact = False)
                if menu([("Yes", True),("No", False)]) == True:
                    narrator("Okay! You open the recursive box.")
                    eRecursiveBoxOpened = True
                    while True:
                        narrator("Inside it is another recursive box.")
                        narrator("You take the recursive box out of the recursive box.")
                        narrator("You open the recursive box.")
            narrator("You leave the box be.")
        else:
            Oak("[prota.Name], this isn't the right time for this.")
            Prota("Professor?")
        item = -1
    return
I know that's a bit more code than usual, but I think everyone should be able to follow the steps.

I'm very afraid I will have to use curry to make the problem (that the player can escape) go away, but I think I'm finally ready for it. It's just I don't know how to use it to solve the problem :(
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)

User avatar
Marionette
Regular
Posts: 128
Joined: Thu Apr 21, 2011 12:04 pm
Completed: https://marionette.itch.io/
Projects: Get Meowt of Here
Deviantart: rexx9224
itch: marionette
Location: Ireland
Discord: Marionette#2995
Contact:

Re: Escape from dialog possible but shouldn't (screen proble

#2 Post by Marionette » Sun Nov 02, 2014 6:15 pm

You could just jump them to a different label and rather than a while loop have it just jump back to the top when done

Code: Select all

...     
   if menu([("Yes", True),("No", False)]) == True:
                    narrator("Okay! You open the recursive box.")
                    eRecursiveBoxOpened = True
                    jump mean_trap


label mean_trap:
  narrator("Inside it is another recursive box.")
  narrator("You take the recursive box out of the recursive box.")
  narrator("You open the recursive box.")
  jump mean_trap
I haven't tested the code, but it should give the desired effect without being stuck in the menu, so in theory the user wont be able to escape from it.

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_