Massages button

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
Ace92
Regular
Posts: 34
Joined: Sun Mar 29, 2009 9:19 am
Contact:

Massages button

#1 Post by Ace92 »

i've entered to my game in progress the "in-games massages system".
and i want to create an on-screen button so the user can enter the massages screen when ever he wants.
i've tried

Code: Select all

init python:

    # 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("Massages", clicked=ccinc("$ show_messages()"xminimum=80)
            ui.close()


    config.overlay_functions.append(button_game_menu)

and i get the eror:
"ScriptError: could not find label ' $ show_messages()'."

what can i do to fix it??

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Massages button

#2 Post by Jake »

Ace92 wrote:

Code: Select all

            ui.textbutton("Massages", clicked=ccinc("$ show_messages()"xminimum=80)
and i get the eror:
"ScriptError: could not find label ' $ show_messages()'."
The problem is that show_messages() is a Python function, and call_in_new_context only jumps to Ren'Py labels. So you need to replace your call with something like:

Code: Select all

            ui.textbutton("Messages", clicked=ccinc("messages"), xminimum=80)
and then create a Ren'Py label with the same name which calls the show_messages() function and then returns:

Code: Select all

label messages:
    $ show_messages()
    return
Server error: user 'Jake' not found

Ace92
Regular
Posts: 34
Joined: Sun Mar 29, 2009 9:19 am
Contact:

Re: Massages button

#3 Post by Ace92 »

when i try to add the:

Code: Select all

label messages:
    $ show_messages()
    return
as a code inisde an init or init python, i get the error:

Code: Select all

On line 165 of D:\Downloads\Testing Scripts/game/script.rpy: invalid syntax
label messages:
              ^
or if i try to put just the code without an init/init python i get:

Code: Select all

ScriptError: could not find label ' messages'.

broken_angel
Veteran
Posts: 322
Joined: Sun Oct 03, 2010 11:49 pm
Completed: Memoirs of an Angel (2010)
Projects: Memoirs of an Angel (Remake); W.I.S.H
Location: United States
Contact:

Re: Massages button

#4 Post by broken_angel »

Labels don't belong in an init or python block.
It's the same as your start label.

Code: Select all

label start:

    This is the beginning of your game.

label messages:
    $ show_messages()
    return

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Massages button

#5 Post by Jake »

Ace92 wrote: or if i try to put just the code without an init/init python i get:

Code: Select all

ScriptError: could not find label ' messages'.
It should be without the init or init python - it looks to me that the error in that case is that you've written " messages" in the ccinc call instead of "messages" - there shouldn't be any spaces between the word 'messages' and the quotes surrounding it, but it looks like you have a space immediately before the first 'm'.


(Arguably this is a bit of a Ren'Py bug, as labels can't have spaces at the beginning or end, so Ren'Py should probably trim them off. But it doesn't, so you need to be careful not to have extraneous spaces when referring to labels.)
Server error: user 'Jake' not found

Ace92
Regular
Posts: 34
Joined: Sun Mar 29, 2009 9:19 am
Contact:

Re: Massages button

#6 Post by Ace92 »

ok now it works thanks! :)
can i put in another script insteed of the Script.rpy?so it won't make a mess out of the script.rpy??
edit:
never mind (:
i used the Jump command :)
thanks again!

Post Reply

Who is online

Users browsing this forum: No registered users