getting a UI error

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
TorroesPrime
Newbie
Posts: 14
Joined: Fri Mar 30, 2018 6:12 pm
Contact:

getting a UI error

#1 Post by TorroesPrime »

In my game I want to have a radio that the player can tune to various FM stations. Most of the stations are offline and just broadcast static, a couple of them have content. So what I'm doing right now is I have a variable 'cur_radio_station' that contains a float value between 88.1 and 107.9 and then I have a function that adjusts that value by .2, takes the new value, converts it into a string, slaps "station_" to the front of it, replaces the "." with a "_" and then jumps to the label of the string

So say you tune up from the default station.
cur_radio_station = 88.3
label_text = "station_"+str(cur_radio_station).replace(".","_")
renpy.jump(label_text )

and then I have a file radio.rpy that has all the labels station_88_1, through station_107_9.

The radio itself is an image map with the functions called in a pair of hotspot actions

So the player starts the game
clicks on the radio
is presented the radio screen (which should already be tuned to whatever the cur_radio_station is), and the game should jump to appropriate station_[cur_radio_station] label.

However I am getting the following error trackback whenever I go to the radio screen:

Code: Select all

I'm sorry, but an uncaught exception occurred.
While running game code:
  File "game/radio.rpy", line 88, in script
    r "Family, hear me!"
Exception: ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?
Stack was <Layer: 'transient'>
<Many: <renpy.display.layout.Fixed object at 0x0000000005dcc9a0>>

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

Full traceback:
  File "game/radio.rpy", line 88, in script
    r "Family, hear me!"
  File "H:\Program Files\Ren'Py\renpy\ast.py", line 930, in execute
    renpy.exports.say(who, what, *args, **kwargs)
  File "H:\Program Files\Ren'Py\renpy\exports.py", line 1474, in say
    who(what, *args, **kwargs)
  File "H:\Program Files\Ren'Py\renpy\character.py", line 1352, in __call__
    self.do_display(who, what, cb_args=self.cb_args, dtt=dtt, **display_args)
  File "H:\Program Files\Ren'Py\renpy\character.py", line 1003, in do_display
    display_say(who,
  File "H:\Program Files\Ren'Py\renpy\character.py", line 693, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "H:\Program Files\Ren'Py\renpy\ui.py", line 293, 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: <renpy.display.layout.Fixed object at 0x0000000005dcc9a0>>

here is the code for the amfm_radio screen:

Code: Select all

screen amfm_radio:
    imagemap:
        ground "images/bg radio.png"
        idle "images/bg radio.png"
        hover "images/bg radio hover.png"
        selected_idle "images/bg radio hover.png"
        selected_hover "images/bg radio hover.png"
        hotspot (784, 604, 75, 45) action fm_radio_up()
        hotspot (861, 600, 82, 54) action fm_radio_down()
        hotspot (988, 596, 138, 59) action NullAction()
    text "{:.1f}".format(cur_radio_station):
        ypos 425 
        xpos 800
        font "font/ticking-timebomb-bb.regular.ttf"
        color "#000000"
        size 120
        text_align 1.0
        
the code for the fm_radio_up function:

Code: Select all

    
    def fm_radio_up():
        global cur_radio_station
        global label_text   
        if cur_radio_station < 107.9:
            cur_radio_station += 0.2
        else:
            cur_radio_station = 88.1
        label_text = "station_"+str(cur_radio_station).replace(".","_")
        renpy.jump(label_text)
the code for the fm_radio_down function:

Code: Select all

    def fm_radio_down():
        global cur_radio_station
        global label_text 
        if cur_radio_station > 88.1:
            cur_radio_station -= 0.2
        else:
            cur_radio_station = 107.9
        label_text = "station_"+str(cur_radio_station).replace(".","_")
        renpy.jump(label_text)
        
Any input would be greatly appreciated.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: getting a UI error

#2 Post by PyTom »

You're calling the actions inside the screen, which is causing problems.

You probably don't want that, instead, you want to write:

Code: Select all

screen amfm_radio:
    imagemap:
        ground "images/bg radio.png"
        idle "images/bg radio.png"
        hover "images/bg radio hover.png"
        selected_idle "images/bg radio hover.png"
        selected_hover "images/bg radio hover.png"
        hotspot (784, 604, 75, 45) action fm_radio_up
        hotspot (861, 600, 82, 54) action fm_radio_down
        hotspot (988, 596, 138, 59) action NullAction()
    text "{:.1f}".format(cur_radio_station):
        ypos 425 
        xpos 800
        font "font/ticking-timebomb-bb.regular.ttf"
        color "#000000"
        size 120
        text_align 1.0
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users