Enter name window when pressing Start button

Forum organization and occasional community-building.
Forum rules
Questions about Ren'Py should go in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
henloanyone
Newbie
Posts: 8
Joined: Wed Mar 06, 2019 11:10 am
Contact:

Enter name window when pressing Start button

#1 Post by henloanyone » Mon Mar 18, 2019 12:49 pm

Can you guys help me show a pop up when pressing the Start button?

What I want is when the player presses Start, a window asking for the player's name would pop up and once the player has entered a name, the game will begin.
I've been trying to use the Special Screen Names in the Ren'Py Documentation but I just can't make it work.

Please help T_T I'm going bald because of this

Mutive
Veteran
Posts: 239
Joined: Tue Nov 21, 2017 2:23 am
Completed: Eidolon, Minion!, Love Furever
Contact:

Re: Enter name window when pressing Start button

#2 Post by Mutive » Mon Mar 18, 2019 12:58 pm

You can always import CYTPES or another Python package. (Screens will only work within Renpy. I don't believe there's a way to have it pop up new frames, but it's doable with a Python call.)
Enjoy Eidolon, my free to play game at: https://mutive.itch.io/eidolon or Minion! at: https://mutive.itch.io/minion

henloanyone
Newbie
Posts: 8
Joined: Wed Mar 06, 2019 11:10 am
Contact:

Re: Enter name window when pressing Start button

#3 Post by henloanyone » Mon Mar 18, 2019 1:09 pm

Mutive wrote:
Mon Mar 18, 2019 12:58 pm
You can always import CYTPES or another Python package. (Screens will only work within Renpy. I don't believe there's a way to have it pop up new frames, but it's doable with a Python call.)
I'm sorry but I'm a beginner both in python and renpy.

Is what I'm asking a bit too advanced for me? Is it completely impossible to do it with just Ren'Py?

User avatar
milksoda
Newbie
Posts: 21
Joined: Mon Sep 05, 2016 5:29 pm
Tumblr: xubearu
Contact:

Re: Enter name window when pressing Start button

#4 Post by milksoda » Mon Mar 18, 2019 5:33 pm

Are you sure you don't just want to use renpy.input()? I did for my games and although it doesn't open a separate window, it worked like a charm.

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

Re: Enter name window when pressing Start button

#5 Post by Imperf3kt » Mon Mar 18, 2019 6:34 pm

The easiest way in my opinion would be to make a screen that includes renpy.input and a button for confirmation.
renpy.input sets the player name using the usual methods, and the button has an action of

Code: Select all

 Return() 
Then you just need to make the screen appear when a player clicks start.

Code: Select all

label start;
    call screen your_screen
By using "call", you can ensure you will return here once a player clicks the confirmation button within the screen that has the action "Return()"

I could give a full coded example later if required. It'll be about 12 hours before I can though.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter

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

Re: Enter name window when pressing Start button

#6 Post by Imperf3kt » Tue Mar 19, 2019 2:58 am

Okay, here's a super simple version. There's no styling or images at all, you'll just get an input box in the middle of the screen

Code: Select all

default player_name = ""
define e = Character('[player_name]')


# The game starts here.

label start:
    
    call screen set_name

    e "Test"

    
    return
    


screen set_name():
    vbox:
        xalign 0.5
        yalign 0.5
        text _("Please input your name")

        input:
            value VariableInputValue('player_name', returnable=True)
It was not necessary to include any buttons or Return() actions as input has "returnable" which does everything for us.

To style this, I'd suggest looking into Ren'Py screen language
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter

henloanyone
Newbie
Posts: 8
Joined: Wed Mar 06, 2019 11:10 am
Contact:

Re: Enter name window when pressing Start button

#7 Post by henloanyone » Wed Mar 20, 2019 1:45 pm

milksoda wrote:
Mon Mar 18, 2019 5:33 pm
Are you sure you don't just want to use renpy.input()? I did for my games and although it doesn't open a separate window, it worked like a charm.
I already managed to use renpy.input(), thankfully...

What I wanted was to put renpy.input() on a window that will show up when the player presses Start. I've been racking my mind but I just can't make it work.
Imperf3kt wrote:
Tue Mar 19, 2019 2:58 am
Okay, here's a super simple version. There's no styling or images at all, you'll just get an input box in the middle of the screen

Code: Select all

default player_name = ""
define e = Character('[player_name]')


# The game starts here.

label start:
    
    call screen set_name

    e "Test"

    
    return
    


screen set_name():
    vbox:
        xalign 0.5
        yalign 0.5
        text _("Please input your name")

        input:
            value VariableInputValue('player_name', returnable=True)
It was not necessary to include any buttons or Return() actions as input has "returnable" which does everything for us.

To style this, I'd suggest looking into Ren'Py screen language
Many thanks! I'll be sure to try this ASAP.

Mutive
Veteran
Posts: 239
Joined: Tue Nov 21, 2017 2:23 am
Completed: Eidolon, Minion!, Love Furever
Contact:

Re: Enter name window when pressing Start button

#8 Post by Mutive » Wed Mar 20, 2019 2:54 pm

This is the documentation for ctypes:

https://docs.python.org/3/library/ctypes.html

I used this to create pop up windows in my game (for which the user can take action that's then recorded in the game). It's probably not the easiest for someone not reasonably familiar with Python, though, and the code will need to be modified for Windows, Linux, and Mac.

My guess is that you're best off using Imperf3kt's method. If you're dead set on a pop up, though, I can share the code I used to create the boxes (and probably even figure out how to add an input field. Mine currently just asks "yes" and "no".)
Enjoy Eidolon, my free to play game at: https://mutive.itch.io/eidolon or Minion! at: https://mutive.itch.io/minion

Post Reply

Who is online

Users browsing this forum: Bing [Bot]