User input variables?

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
User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

User input variables?

#1 Post by OokamiKasumi »

Hi, I'd like to make a kinetic novel that involves using a list of things (input) given by the user that becomes part of the story. How would I code something like that? I did search the archives, which gave me renpy.input, but I'm a little confused by what I'm looking at.
$ name = renpy.input("What is your name?", "Joe User", length=20)
e "Pleased to meet you, %(name)s."
For my story, I need about 10 different things, all of which are used later in the body of the story. Just so you know, I'm not using character boxes. I'm doing this NVL style, so I don't think Dynamic Character will be needed.

Here are some of the user input questions:
~~~~~~~~~~~~~
Name your Hero: Example: Tom, Dick, Shinji
Name your Other Hero:
Name a Female Friend: Example: Mary, Crystal, Megumi

Please help?
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

shylock
Regular
Posts: 35
Joined: Wed Oct 13, 2010 11:57 am
Projects: Isle of St. Marcus, `Silver Seas'
Location: Upstate NY
Contact:

Re: User input variables?

#2 Post by shylock »

I'm not sure what's to help?

So the first line says: take a variable, name. then prompt the user to enter a string of maximum length 20 to the query "What is your name?" with a default option "Joe User". then store that string as name.

The "%(name)s" tells the game to display name, and that name is a string.

Just throw that code in your game and see what it does yourself.

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: User input variables?

#3 Post by OokamiKasumi »

shylock wrote:I'm not sure what's to help?

So the first line says: take a variable, name. then prompt the user to enter a string of maximum length 20 to the query "What is your name?" with a default option "Joe User". then store that string as name.

The "%(name)s" tells the game to display name, and that name is a string.

Just throw that code in your game and see what it does yourself.
Doesn't the 'e' at the beginning of the second string mean it's supposed to go in a specific character box?
e "Pleased to meet you, %(name)s.
The problem is, I'm not using a character box and I need over a dozen different variables. Even so, I'll throw it in there and see what I get.

(Tick-tock...Tick-tock...)

After some experimentation, I was able to get it to work, but that text appears in a Character window --> http://www.yaoi.ca/gallery/main.php?g2_ ... alNumber=2

While everything else appears in a Novel window -->
http://www.yaoi.ca/gallery/main.php?g2_ ... alNumber=2

The code I ended up using was This:
window show
"The trick is to backspace over the letters, then type in your choice."
nvl clear

$m1 = renpy.input("Name your hero:", "Hero", length=20)
"%(m1)s, that's good."
nvl clear

$m2 = renpy.input("Name your Other Hero:", "Other Hero", length=20)
"%(m2)s that's good too."
The reply statements: "%(m1)s, that's good." showed up in the Novel window.

Is there absolutely no way to get it to show up in the novel window?
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: User input variables?

#4 Post by Aleema »

Whatever limitation you think is there is not there. NVL mode and regular mode use variables in the same way. You can also use characters in NVL mode, too. You just have to put the parameter "kind=nvl" inside your character definition. You can use a character called "e" if you wanted. You just have to put "kind=NVL" like this:

Code: Select all

$ e = Character("Eileen", color="#c8ffc8", kind=nvl)
This is all on the NVL page.

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: User input variables?

#5 Post by OokamiKasumi »

Aleema wrote:Whatever limitation you think is there is not there. NVL mode and regular mode use variables in the same way. You can also use characters in NVL mode, too. You just have to put the parameter "kind=nvl" inside your character definition. You can use a character called "e" if you wanted. You just have to put "kind=NVL" like this:

Code: Select all

$ e = Character("Eileen", color="#c8ffc8", kind=nvl)
This is all on the NVL page.
This is the code I used:
init:
$ menu = nvl_menu

image eileen happy = "eileen_happy.png"
image bg_uni = "uni.jpg"

$ narrator = NVLCharacter(None, kind=nvl, window_left_margin = 1, window_right_margin = 375)
$ m1 = Character("Hero", kind=nvl, window_left_margin = 1, window_right_margin = 375)
$ m2 = Character("Other Hero", kind=nvl, window_left_margin = 1, window_right_margin = 375)

# The game starts here.
label start:
scene bg_uni
with fade

show eileen happy at right
with dissolve

window show
"The trick is to backspace over the letters, then type in your choice."
nvl clear

$m1 = renpy.input("Name your hero:", "Hero", length=20)
"%(m1)s, that's good."
nvl clear

$m2 = renpy.input("Name your Other Hero:", "Other Hero", length=20)
"%(m2)s that's good too."
It still appears in the bottom box.

If I put it in this line:
This way:
$m1 = renpy.input("Name your hero:", "Hero", kind=nvl, length=20)
Or this way:
$m1 = renpy.input("Name your hero:", "Hero", kind=nvl, length=20, kind=nvl)
I get This error message:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 1: ordinal not in range(128)

While compiling python block starting at line 33 of I:\!Kenetic Novels\RenPy\YaoiStory/game/script.rpy.

-- Full Traceback ------------------------------------------------------------

File "I:\!Kenetic Novels\RenPy\renpy-6.11.2\renpy\bootstrap.py", line 270, in bootstrap
File "I:\!Kenetic Novels\RenPy\renpy-6.11.2\renpy\main.py", line 173, in main
File "I:\!Kenetic Novels\RenPy\renpy-6.11.2\renpy\script.py", line 498, in load_script
File "I:\!Kenetic Novels\RenPy\renpy-6.11.2\renpy\script.py", line 165, in __init__
File "I:\!Kenetic Novels\RenPy\renpy-6.11.2\renpy\script.py", line 381, in load_appropriate_file
File "I:\!Kenetic Novels\RenPy\renpy-6.11.2\renpy\script.py", line 343, in load_file
File "I:\!Kenetic Novels\RenPy\renpy-6.11.2\renpy\script.py", line 445, in update_bytecode
File "I:\!Kenetic Novels\RenPy\renpy-6.11.2\renpy\parser.py", line 65, in __init__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 1: ordinal not in range(128)

While compiling python block starting at line 33 of I:\!Kenetic Novels\RenPy\YaoiStory/game/script.rpy.

Ren'Py Version: Ren'Py 6.11.2b
What am I doing wrong?
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: User input variables?

#6 Post by Aleema »

Okay, I see what you're complaining about.

Like most things in Ren'Py, you'll have to style them to fit your needs. You can style the input window to fit your needs. Mess around with the input_window and input_text styles until they mimic your NVL arrangement. You can edit styles just like you see in options.rpy (for example):

Code: Select all

    style.input_window.left_margin = 100
    style.input_window.right_margin = 100
    style.input_window.left_padding = 100
    style.input_window.right_padding = 100
    style.input_text.size = 18
    style.input_text.color = "#fff"
I think that might be the best/only way. If there's a magical line of code that embeds it, I don't know of it.

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: User input variables?

#7 Post by OokamiKasumi »

Aleema wrote:Okay, I see what you're complaining about.

Like most things in Ren'Py, you'll have to style them to fit your needs. You can style the input window to fit your needs. Mess around with the input_window and input_text styles until they mimic your NVL arrangement. ...
I think that might be the best/only way. If there's a magical line of code that embeds it, I don't know of it.
Thank you so much for at least looking into it for me.
I had no idea that I could actually name and configure a whole different window!
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

Post Reply

Who is online

Users browsing this forum: Google [Bot], piinkpuddiin