Page 1 of 1
Enter name window when pressing Start button
Posted: Mon Mar 18, 2019 12:49 pm
by henloanyone
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
Re: Enter name window when pressing Start button
Posted: Mon Mar 18, 2019 12:58 pm
by Mutive
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.)
Re: Enter name window when pressing Start button
Posted: Mon Mar 18, 2019 1:09 pm
by henloanyone
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?
Re: Enter name window when pressing Start button
Posted: Mon Mar 18, 2019 5:33 pm
by milksoda
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.
Re: Enter name window when pressing Start button
Posted: Mon Mar 18, 2019 6:34 pm
by Imperf3kt
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
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.
Re: Enter name window when pressing Start button
Posted: Tue Mar 19, 2019 2:58 am
by Imperf3kt
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
Re: Enter name window when pressing Start button
Posted: Wed Mar 20, 2019 1:45 pm
by henloanyone
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.
Re: Enter name window when pressing Start button
Posted: Wed Mar 20, 2019 2:54 pm
by Mutive
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".)