Page 1 of 1

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

Posted: Fri Oct 03, 2014 9:39 am
by Ayutac
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 :(

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

Posted: Sun Nov 02, 2014 6:15 pm
by Marionette
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.