How do I create buttons?

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
Lutka
Newbie
Posts: 23
Joined: Mon Apr 24, 2017 11:13 am
Contact:

How do I create buttons?

#1 Post by Lutka »

Right, I know, I know, I'm dumb.

If you couldn't tell, I'm new here

Thing is, seemingly nowhere in these guides does it say how I'm to create buttons. What I came up with after googling for like 30 minutes is this:

button:
text "example"
action Jump("on_smile_1")

I'm not a complete noobie to this stuff though, so I know what this button is supposed to do; when you click the button that says "example" you will jump forward in the code to the point "on_smile_1". But that doesn't work. When I launch my project it brings up:

File "game/script.rpy", line 52: expected statement.
button:
^

File "game/script.rpy", line 55: expected statement.
button:
^

Which I think might have something to do with indentation, but I'm not sure considering how many different types of indentation I've tried on this damn thing

What I want is to have two or more buttons appear in the middle of the bottom of the screen side by side and clicking those (through the action property) will work just like choice menu buttons . It seems that buttons are easier to move around on the screen than choice menu buttons, which is why I want to use them. Unless one of you can tell me how I'm to move around choice menu buttons? They seem quite glued to the center of the screen.


Thanks

Lutka
Newbie
Posts: 23
Joined: Mon Apr 24, 2017 11:13 am
Contact:

Re: How do I create buttons?

#2 Post by Lutka »

Alrighto, so I kept messing around and there was in fact a spot I'd missed over in screens.rpy called style choice_vbox. Messing with the xalign and yalign there'll do ya.

Lutka
Newbie
Posts: 23
Joined: Mon Apr 24, 2017 11:13 am
Contact:

Re: How do I create buttons?

#3 Post by Lutka »

One thing that still would be nice, is getting the two (or more) options to go next to each other in a nice line rather than on top of each other. Is this plausible?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: How do I create buttons?

#4 Post by Imperf3kt »

the syntax is

Code: Select all

textbutton "example"
    jump on_smile_1
Ren'Py includes a handy documentation if you ever forget these things. Just look at the bottom left of the program.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Lutka
Newbie
Posts: 23
Joined: Mon Apr 24, 2017 11:13 am
Contact:

Re: How do I create buttons?

#5 Post by Lutka »

Imperf3kt wrote:the syntax is

Code: Select all

textbutton "example"
    jump on_smile_1
Thank you

So I tried this instead of the choice menu,but i get this error when the game reaches the point where the button comes in:

While running game code:
File "game/script.rpy", line 54, in script
textbutton "Forgive"
Exception: Sayer 'textbutton' is not defined.

I believe the game thinks that 'textbutton' is actually a character, therefore an undefined 'sayer'. But as has been discovered throughout this thread, I could be wrong.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: How do I create buttons?

#6 Post by Imperf3kt »

Its waaaay too early here...

What you want is a choice menu:

Code: Select all

menu:
    "option 1":
        jump on_smile_1
    "option 2":
        jump another_label

#carry on
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: No registered users