Calling Multiple 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
tapanojum
Regular
Posts: 27
Joined: Tue Feb 27, 2018 4:33 am
Contact:

Calling Multiple Buttons?

#1 Post by tapanojum » Sat Dec 14, 2019 11:14 am

Hi, is it possible to call more than one button at a time? I've tried searching the board but the site times out before I can get a result. I know I can do an imagemap but I'm wondering if it's possible to do several buttons at once.

Thanks!

User avatar
Per K Grok
Miko-Class Veteran
Posts: 673
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
itch: per-k-grok
Location: Sverige
Contact:

Re: Calling Multiple Buttons?

#2 Post by Per K Grok » Sat Dec 14, 2019 1:15 pm

tapanojum wrote:
Sat Dec 14, 2019 11:14 am
Hi, is it possible to call more than one button at a time? I've tried searching the board but the site times out before I can get a result. I know I can do an imagemap but I'm wondering if it's possible to do several buttons at once.

Thanks!
I'm not sure I understand you correctly, but you make a button as part of a screen, and you can have as many buttons in that screen as there is space for.

Code: Select all

screen map():
    textbutton "Home" action Jump("home") pos (5, 30)
    textbutton "Park" action Jump("park") pos (5, 50)
    textbutton "School" action Jump("school") pos (5, 70)

User avatar
dGameBoy101b
Newbie
Posts: 21
Joined: Sun Aug 12, 2018 8:32 am
itch: dgameboy101b
Contact:

Re: Calling Multiple Buttons?

#3 Post by dGameBoy101b » Sat Dec 14, 2019 1:16 pm

You can group together various screen elements, like buttons, using various grouping elements like vertical boxes, horizontal boxes, grids, fixed size boxes, or just by listing multiple elements in the screen.

Code: Select all

screen test:
	vbox:
		button "Skip" action Skip()
		button "Save" action ShowMenu('save')

tapanojum
Regular
Posts: 27
Joined: Tue Feb 27, 2018 4:33 am
Contact:

Re: Calling Multiple Buttons?

#4 Post by tapanojum » Sun Dec 15, 2019 3:56 am

Thank you guys. Sorry for the confusing question. I shouldn't write questions at 7 am after pulling an all-nighter to hit deadlines. Looks like my understanding of screens and buttons were fundamentally wrong. I was creating 1 screen per button and because of that wasn't able to see multiple buttons since you can only call one screen at a time.

I will not put all the buttons for any given scene on one screen instead.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 673
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
itch: per-k-grok
Location: Sverige
Contact:

Re: Calling Multiple Buttons?

#5 Post by Per K Grok » Sun Dec 15, 2019 6:50 am

tapanojum wrote:
Sun Dec 15, 2019 3:56 am
----
I was creating 1 screen per button and because of that wasn't able to see multiple buttons since you can only call one screen at a time.

----
You can have more than one screen on at once using show menu, so you are not necessarily limited to show one screen at the time. Usually it is practical to have all elements you want in one screen, but it is not necessary.

When you are thinking about screens I don't think you should primarily think about it in terms of the graphics. Screens is what is used for the user to communicate with the game. Dialogue, quickmenu and chose menus are also screens.

You can have screens without any graphics.

Here you have an example of a screen with no graphics that takes keyboard input (q, w and e) to jump between labels.

Code: Select all

screen keys():
    key "q" action Jump("home_")
    key "w" action Jump("park_")
    key "e" action Jump("school_")

label start:
    show screen keys


label home_:
    "Welcome home."

    pause

label park_:
    "Welcome to the park."

    pause

label school_:
    "Welcome to the school."

    pause

tapanojum
Regular
Posts: 27
Joined: Tue Feb 27, 2018 4:33 am
Contact:

Re: Calling Multiple Buttons?

#6 Post by tapanojum » Sun Dec 15, 2019 6:41 pm

Thank you Per K Grok, that was really informative and helpful!

Post Reply

Who is online

Users browsing this forum: Google [Bot]