Imagebutton Code Problem

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
Vaponizer
Newbie
Posts: 1
Joined: Sun Aug 14, 2022 6:18 pm
Contact:

Imagebutton Code Problem

#1 Post by Vaponizer » Mon Aug 15, 2022 12:15 pm

Hey there

I want to make an Imagebutton but something is wrong with my code. It says "File "game/script.rpy", line 147: expected statement. (see PNG)
I also attached my script....
This is where its not working;

if scene w17:

imagebutton auto "images/mm_w171a_%s.jpg"
action jump w17a
"Jason""Eine Leiche?"
" ""Gulp"
"Jason""Ich sollte an die Tür gehen"
show w17

Im really new into coding so im trying to get every expertise or help i become. If there is something fundamentally missing pls tell me!
Attachments
script.rpy
(4.39 KiB) Downloaded 4 times
Unbenannt.PNG

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

Re: Imagebutton Code Problem

#2 Post by Alex » Mon Aug 15, 2022 1:06 pm

Vaponizer wrote:
Mon Aug 15, 2022 12:15 pm
Hey there

I want to make an Imagebutton but something is wrong with my code. It says "File "game/script.rpy", line 147: expected statement. (see PNG)
...
First thing is that imagebutton should be a part of the screen. Then you need to show or call this screen to let player interact with it. And 'jump' is not valid action for imagebutton - should be 'Jump".
https://www.renpy.org/doc/html/screen_actions.html#Jump

Also, 'if scene w17:' will not work, 'cause name of variable should be a single word (that must start from letter and may have letters, digits and underscores).
So, try

Code: Select all

default flag_variable = False

screen some_screen_name():
    imagebutton auto "images/mm_w171a_%s.jpg" action Jump('w17a') align(0.5, 0.5)

label w17a:
    hide screen some_screen_name
    "Secret ending."
    return

label start:
    "no button on screen"
    menu:
        "Want to see the button?"
        "Yes":
            $ flag_variable = True
        "No":
            pass
    if flag_variable:
        show screen some_screen_name
        "now you can click the button..."
        "...if you wish."
        hide screen some_screen_name
    "well..."
    "neutral ending"
    return
https://www.renpy.org/doc/html/screens.html
https://www.renpy.org/doc/html/screen_actions.html
https://www.renpy.org/doc/html/python.html
https://www.renpy.org/doc/html/language ... statements

Post Reply

Who is online

Users browsing this forum: Google [Bot]