On screen Menu button with Text History 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
User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

On screen Menu button with Text History error

#1 Post by AERenoir »

I tried using the text history code http://www.renpy.org/wiki/renpy/doc/coo ... xt_History with the On screen Menu code http://www.renpy.org/wiki/renpy/doc/coo ... _Game_Menu.

On the script.rpy file my code looks like this:

Code: Select all

init python:
# This file adds a number of buttons to the lower-right hand corner of
# the screen. Three of these buttons jump to the game menu, which
# giving quick access to Load, Save, and Prefs. The fourth button
# toggles skipping, to make that more convenient.

    # Give us some space on the right side of the screen.
    style.window.right_padding = 100

    def toggle_skipping():
        config.skipping = not config.skipping

    show_button_game_menu = True

    def button_game_menu():
        
        if show_button_game_menu:

            # to save typing
            ccinc = renpy.curried_call_in_new_context

            ui.vbox(xpos=0.99, ypos=0.98, xanchor='right', yanchor='bottom')
            ui.textbutton("Skip", clicked=toggle_skipping, xminimum=80)
            ui.textbutton("Save", clicked=ccinc("_game_menu_save"), xminimum=80)
            ui.textbutton("Load", clicked=ccinc("_game_menu_load"), xminimum=80)
            ui.textbutton("Prefs", clicked=ccinc("_game_menu_preferences"), xminimum=80)
            ui.textbutton ('Text History', clicked=ccinc("_game_menu_text_history"), xminimum=80)
            ui.close()


    config.window_overlay_functions.append(button_game_menu)
    


And I put the Cookbook text history code in a separate *.rpy file called "readback.rpy". Then I get errors like this:

Code: Select all

I'm sorry, but an uncaught exception occurred.

ScriptError: could not find label '_game_menu_text_history'.

While running game code:
 - script at line 354 of G:\Game/game/script.rpy

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

  File "G:\Downloads\renpy-6.12.0\renpy\bootstrap.py", line 279, in bootstrap
  File "G:\Downloads\renpy-6.12.0\renpy\main.py", line 320, in main
  File "G:\Downloads\renpy-6.12.0\renpy\main.py", line 93, in run
  File "G:\Downloads\renpy-6.12.0\renpy\execution.py", line 259, in run
  File "G:\Downloads\renpy-6.12.0\renpy\ast.py", line 367, in execute
  File "G:\Downloads\renpy-6.12.0\renpy\exports.py", line 631, in say
  File "G:\Downloads\renpy-6.12.0\renpy\store.py", line 352, in say
  File "G:\Downloads\renpy-6.12.0\renpy\character.py", line 697, in __call__
  File "G:\Downloads\renpy-6.12.0\renpy\character.py", line 651, in do_display
  File "G:\Downloads\renpy-6.12.0\renpy\character.py", line 467, in display_say
  File "G:\Downloads\renpy-6.12.0\renpy\ui.py", line 236, in interact
  File "G:\Downloads\renpy-6.12.0\renpy\display\core.py", line 1627, in interact
  File "G:\Downloads\renpy-6.12.0\renpy\display\core.py", line 2205, in interact_core
  File "G:\Downloads\renpy-6.12.0\renpy\display\layout.py", line 672, in event
  File "G:\Downloads\renpy-6.12.0\renpy\display\layout.py", line 672, in event
  File "G:\Downloads\renpy-6.12.0\renpy\display\layout.py", line 672, in event
  File "G:\Downloads\renpy-6.12.0\renpy\display\layout.py", line 672, in event
  File "G:\Downloads\renpy-6.12.0\renpy\display\behavior.py", line 601, in event
  File "G:\Downloads\renpy-6.12.0\renpy\display\behavior.py", line 187, in run
  File "G:\Downloads\renpy-6.12.0\renpy\curry.py", line 38, in __call__
  File "G:\Downloads\renpy-6.12.0\renpy\game.py", line 297, in call_in_new_context
  File "G:\Downloads\renpy-6.12.0\renpy\execution.py", line 246, in run
  File "G:\Downloads\renpy-6.12.0\renpy\script.py", line 480, in lookup
ScriptError: could not find label '_game_menu_text_history'.

While running game code:
 - script at line 354 of G:\Game/game/script.rpy

Ren'Py Version: Ren'Py 6.12.0e
What is wrong?

While we're at it, how do I use image buttons as the menu buttons and move it elsewhere? I don't particularly like it being in the bottom right corner and I want to customize their looks.

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: On screen Menu button with Text History error

#2 Post by Elmiwisa »

"_game_menu_text_history" have to be label name rather than screen name, call the screen from that label instead. Though you might be better off simply by calling the menu directly.

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: On screen Menu button with Text History error

#3 Post by AERenoir »

I'm not sure I understand what you mean? :O Should the text history code not be on a separate rpy or something? The menu button script was already in the script.rpy, not screens.

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: On screen Menu button with Text History error

#4 Post by Elmiwisa »

:| :| :|
Seems like you did not understand what I said at all. :cry:
I am talking about how changing the screen's name to "_game_menu_text_history" won't help you fix the issue since that need to be a label name.
...
Here is a way to fix it. Change the screen's name back to "text_history" just like how the original did it. Then add this somewhere:

Code: Select all

label _game_menu_text_history:
    call screen text_history
    return
Then it should work. Not exactly the most elegant solution, but it involve least amount of work you need to do to fix it.

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: On screen Menu button with Text History error

#5 Post by AERenoir »

Oh, I didn't actually change anything. I forgot to declare "_game_menu_text_history" >.< Or rather, I didn't know I had to do that because I was using two scripts together and I didn't know how to make them work with each other D:

So, uh, now that I managed to get this thing to work, I want to know if I can modify this Return button? There's a blue diamond-shaped button at the corner of the "return" button on the text log screen and I kind of want to get rid of it.
Log screen.jpg

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: On screen Menu button with Text History error

#6 Post by Elmiwisa »

Ah I see, I thought you renamed the text_history screen into _game_menu_text_history.

That diamond thing is not part of the button. It's the thumb of the scroll bar, that happened to be at the button's location because of positioning choice.
Move the button somewhere else, or the scroll bar somewhere else, by specifying the position on the last 2 lines of the text history code. Or you could remove the thumb completely by making thumb None for the bar, but it's probably not a good idea.

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: On screen Menu button with Text History error

#7 Post by AERenoir »

Hmm, is there a padding code to it? I can't seem to move the scroller even though I added "align" and fiddled with it. I'd like to move it to the right a bit more because it kind of cramps up the screen being bumped so far in from the right margin.

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: On screen Menu button with Text History error

#8 Post by Elmiwisa »

The bar is controlled by this line:

Code: Select all

  bar adjustment adj style 'vscrollbar'
Which is the 2nd line from the bottom in the text history code.

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: On screen Menu button with Text History error

#9 Post by AERenoir »

Yeah, I changed my question because I found it. Sorry. So I wasn't sure what to do to move it aside.

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: On screen Menu button with Text History error

#10 Post by Elmiwisa »

Delete some of the indentation of that line to make it match the indentation of textbutton line.
Look at the line that say

Code: Select all

side "c r":
and remove the "r".

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: On screen Menu button with Text History error

#11 Post by AERenoir »

I did that and it's still indented too deep.
Log screen.jpg
The code block looks like this:

Code: Select all

window:
        style_group "readback"
    
        side "c ":
            
            frame:
                
                $ vp = ui.viewport(mousewheel = True, draggable = True, offsets=(0.0, yvalue), yadjustment = adj)

                vbox:
                    null height 10
                    
                    for line in lines_to_show:
                        
                        if line[0] and line[0] != " ":
                            label line[0] # name

                        # if there's no voice just log a dialogue
                        if not line[2]:
                            text line[1]
                            
                        # else, dialogue will be saved as a button of which plays voice when clicked
                        else: 
                            textbutton line[1] action Play("voice", line[2] )
                        
                        null height 10
                
        bar adjustment adj style 'vscrollbar' align (1.0, 1.0)
        textbutton _("Return") action Return() align (.8, 1.0)

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: On screen Menu button with Text History error

#12 Post by Elmiwisa »

Oh I forgot about the padding. You need to reduce the xpadding property in the style sheet for readback_frame too, which is somewhere near the top of the text history code.

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: On screen Menu button with Text History error

#13 Post by AERenoir »

You mean this?

Code: Select all

 style.readback_frame.background = None
    style.readback_frame.xpadding = 5
    style.readback_frame.xmargin = 5
    style.readback_frame.ymargin = 5
Changed them around, nothing happened. I didn't thing 5 pixels of padding would make that big an indentation.

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: On screen Menu button with Text History error

#14 Post by Elmiwisa »

Ah sorry I misread that part of the code. I thought that code set style for readback_window but now that I read carefully it is for readback_frame. :oops:
You need set the xpadding (or at least the right_padding) for readback_window instead. If you don't set the padding, then it will assume the value of padding of a general window. And based on your other thread which you mentioned changing the padding to make the text centred, you probably have very large padding amount for a general window, which cause the bar to be pushed in.
So something like this:

Code: Select all

style.readback_window.right_padding=0

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: On screen Menu button with Text History error

#15 Post by AERenoir »

Ooh. Darn, I didn't know that textbox padding I set up affects this screen too. Thanks~

Post Reply

Who is online

Users browsing this forum: No registered users