Choice Displayed with brief pause inbetween items?

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
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Choice Displayed with brief pause inbetween items?

#1 Post by wyverngem »

Is there a way in the choice menu to add a brief pause between choices so they don't all show up at once? I wanted to add a sort of delayed effect to the menu, but I can't seem to code it. I've tried adding a simple $ renpy.pause(1), but it crashes the game.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/chapter1.rpy", line 182, in script
    menu:
  File "game/choice_screen.rpy", line 9, in execute
    screen choice(items):
  File "game/choice_screen.rpy", line 9, in execute
    screen choice(items):
  File "game/choice_screen.rpy", line 95, in execute
    for i in items:
  File "game/choice_screen.rpy", line 137, in execute
    $ renpy.pause(1)
  File "game/choice_screen.rpy", line 137, in <module>
    $ renpy.pause(1)
Exception: ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?
Stack was <Layer: 'transient'>
<Many: <Fixed at 955b210>>

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/chapter1.rpy", line 182, in script
    menu:
  File "G:\Creative\VN\Renpy\renpy\ast.py", line 1459, in execute
    choice = renpy.exports.menu(choices, self.set)
  File "G:\Creative\VN\Renpy\renpy\exports.py", line 847, in menu
    rv = renpy.store.menu(items)
  File "G:\Creative\VN\Renpy\renpy\exports.py", line 1005, in display_menu
    show_screen(screen, items=item_actions, _widget_properties=props, _transient=True, _layer=renpy.config.choice_layer, **scope)
  File "G:\Creative\VN\Renpy\renpy\display\screen.py", line 1041, in show_screen
    sls.add(_layer, d, _tag, zorder=d.zorder, transient=_transient, keep_st=True, name=name)
  File "G:\Creative\VN\Renpy\renpy\display\core.py", line 1009, in add
    self.hide_or_replace(layer, remove_index, "replaced")
  File "G:\Creative\VN\Renpy\renpy\display\core.py", line 1031, in hide_or_replace
    d = oldsle.displayable._hide(now - st, now - at, prefix)
  File "G:\Creative\VN\Renpy\renpy\display\screen.py", line 443, in _hide
    self.update()
  File "G:\Creative\VN\Renpy\renpy\display\screen.py", line 578, in update
    self.screen.function(**self.scope)
  File "game/choice_screen.rpy", line 9, in execute
    screen choice(items):
  File "game/choice_screen.rpy", line 9, in execute
    screen choice(items):
  File "game/choice_screen.rpy", line 95, in execute
    for i in items:
  File "game/choice_screen.rpy", line 137, in execute
    $ renpy.pause(1)
  File "game/choice_screen.rpy", line 137, in <module>
    $ renpy.pause(1)
  File "G:\Creative\VN\Renpy\renpy\exports.py", line 1278, in pause
    rv = renpy.ui.interact(mouse='pause', type='pause', roll_forward=roll_forward)
  File "G:\Creative\VN\Renpy\renpy\ui.py", line 279, in interact
    raise Exception("ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?\nStack was "+('\n'.join([str(item) for item in stack])))
Exception: ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?
Stack was <Layer: 'transient'>
<Many: <Fixed at 955b210>>

Windows-7-6.1.7601-SP1
Ren'Py 6.99.12.4.2187

User avatar
Belgerum
Regular
Posts: 110
Joined: Thu Nov 06, 2014 12:24 am
Skype: belgerum09
Soundcloud: Belgerum
itch: Belgerum
Contact:

Re: Choice Displayed with brief pause inbetween items?

#2 Post by Belgerum »

This is something that won't be easily accomplished in the script. The effect is possible, however.

One way to do it is to program the choice menu in screens.rpy to have a number of variant transforms for each choice, with incrementing pauses before they fade in, which is similar to how it seems you're trying to make it happen.

Here's an example, though it will only work for up to 6 choices:

Code: Select all

screen choice(items):
    style_prefix "choice"
    vbox:
        for i in items:
            textbutton i.caption action i.action xalign 0.5:
                if len(items) > 0:
                    if items[0].caption == i.caption and items[0].action == i.action:
                        at choice_button_alpha1
                if len(items) > 1:
                    if items[1].caption == i.caption and items[1].action == i.action:
                        at choice_button_alpha2
                if len(items) > 2:
                    if items[2].caption == i.caption and items[2].action == i.action:
                        at choice_button_alpha3
                if len(items) > 3:
                    if items[3].caption == i.caption and items[3].action == i.action:
                        at choice_button_alpha4
                if len(items) > 4:
                    if items[4].caption == i.caption and items[4].action == i.action:
                        at choice_button_alpha5
                if len(items) > 5:
                    if items[5].caption == i.caption and items[5].action == i.action:
                        at choice_button_alpha6

init -2:
    transform choice_button_alpha1:
        alpha 0.0
        pause 0.0
        ease 0.2 alpha 1.0
    transform choice_button_alpha2:
        alpha 0.0
        pause 0.2
        ease 0.2 alpha 1.0
    transform choice_button_alpha3:
        alpha 0.0
        pause 0.4
        ease 0.2 alpha 1.0
    transform choice_button_alpha4:
        alpha 0.0
        pause 0.6
        ease 0.2 alpha 1.0
    transform choice_button_alpha5:
        alpha 0.0
        pause 0.8
        ease 0.2 alpha 1.0
    transform choice_button_alpha6:
        alpha 0.0
        pause 1.0
        ease 0.2 alpha 1.0
Feel free to use that, or modify it to suit your needs.

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

Re: Choice Displayed with brief pause inbetween items?

#3 Post by Alex »

Kind of example

Code: Select all

transform my_tr(t):
    alpha 0.0 xoffset -20
    t/5.0 # do not forget decimal part
    parallel:
        ease 0.5 alpha 1.0
    parallel:
        ease 0.3 xoffset 20
        ease 0.2 xoffset 0
    
screen choice(items):
    
    window:
        style "menu_window"
        xalign 0.5
        yalign 0.5

        vbox:
            style "menu"
            spacing 2

            for t, (caption, action, chosen) in enumerate(items): # t would have value for each choice (start from 0, step 1)

                if action:

                    button:
                        at my_tr(t) # apply transform with t as argument
                        action action
                        style "menu_choice_button"

                        text caption style "menu_choice"

                else:
                    text caption style "menu_caption" at my_tr(t) # apply transform with t as argument

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]