Names inside Dialogue?

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
Skittle Sama
Newbie
Posts: 12
Joined: Sat Apr 23, 2005 1:43 pm
Location: Sarasota, Fl.
Contact:

Names inside Dialogue?

#1 Post by Skittle Sama »

Strange, I was reading over the old topic of 'custom names' to remember how to create a user inputted name. However, mid-workings into a dialogue in the game, I noticed something.

If you have a character speaking, is it possible to have them refer to the user inputted name in the actual dialogue? If so, I'm not sure how to do that. Perhaps one of you could answer that question for me?

I'll show you what I mean via example:

The user types their character's name as ... "Cindy". Rather than have this situation:

Ex. #1

Cindy: "That's when I saw him!"
Bob: "Hello."

I would much rather have:

Ex. #2

Cindy: "That's when I saw him!"
Bob: "Hello, Cindy."


Any takers?

ShiraiJunichi
Miko-Class Veteran
Posts: 651
Joined: Sat May 21, 2005 12:28 pm
Location: University of Utah
Contact:

#2 Post by ShiraiJunichi »

Yeah- just set the input to a variable:

$ variable_name = renpy.input("A question")

And then just insert it like so:

"ShiraiJunichi" "Your answer to the question was %(variable_name)s"

At least, that's how it's coded in the demo

Skittle Sama
Newbie
Posts: 12
Joined: Sat Apr 23, 2005 1:43 pm
Location: Sarasota, Fl.
Contact:

#3 Post by Skittle Sama »

Problem Fixed!
Solved my own problem! The name variable worked perfectly! Thank you SJ.

Skittle Sama
Newbie
Posts: 12
Joined: Sat Apr 23, 2005 1:43 pm
Location: Sarasota, Fl.
Contact:

#4 Post by Skittle Sama »

I take that back. Now my problem must me in the coding itself:

Code: Select all

init:
    python:
        def p(what):
            renpy.display_say(player, what, color=(255, 255, 0, 255))

        p.say = p

$ player = renpy.prompt("Please enter your name:", "", 30)

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#5 Post by PyTom »

That's a really old-school way of doing what should now be written as:

Code: Select all

init:
    $ p = DynamicCharacter("player", color=(255, 255, 0, 255))

$ player = renpy.input("Please enter your name:", "", length=30)
I also note that it's renpy.input, not renpy.prompt.
Last edited by PyTom on Tue Jun 14, 2005 7:10 am, edited 1 time in total.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Skittle Sama
Newbie
Posts: 12
Joined: Sat Apr 23, 2005 1:43 pm
Location: Sarasota, Fl.
Contact:

#6 Post by Skittle Sama »

Oh? Thank you Pytom! I appreciate the update. I didn't know that the code had been changed.

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

ParseError: On line 239 of game/script.rpy: one-line python statement does not expect a block.

$ player = renpy.input("Please enter your name:", "", 30)
                                                         ^

While parsing game/script.rpy.

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

  File "run_game.py", line 62, in main
  File "renpy\main.pyc", line 154, in main
  File "renpy\script.pyc", line 189, in load_script
  File "renpy\script.pyc", line 83, in __init__
  File "renpy\script.pyc", line 109, in load_file
  File "renpy\parser.pyc", line 1216, in parse
  File "renpy\parser.pyc", line 1192, in parse_block
  File "renpy\parser.pyc", line 1090, in parse_statement
  File "renpy\parser.pyc", line 364, in expect_noblock
  File "renpy\parser.pyc", line 337, in error
ParseError: On line 239 of game/script.rpy: one-line python statement does not expect a block.

$ player = renpy.input("Please enter your name:", "", 30)
                                                         ^

While parsing game/script.rpy.

Ren'Py Version: Ren'Py 4.8.5
... Lord, almighty...

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#7 Post by PyTom »

This error isn't caused by the code you have here. The problem is, the code after the input is indented. It's as if you wrote something like:

Code: Select all

label foo:

     "Line 1"

$ player = renpy.input(...)

     "Line 2"
The solution is to indent the python line to the level of the surrounding script, or to dedent the following lines out to the level of the python line. Either way will solve the problem.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Skittle Sama
Newbie
Posts: 12
Joined: Sat Apr 23, 2005 1:43 pm
Location: Sarasota, Fl.
Contact:

#8 Post by Skittle Sama »

Odd, I still seem to be getting error messages. I made sure that the lines weren't indented after that, but I'm still getting error messages. If I have the input code there, does that mean that all the rest of the game script will have to be be 'un-indented' as well?

Sorry to be such a bother to you. I'm sure that this is a simple answer, but I'm just not seeing it. If I don't indent every line, I will most likely just receive this everytime, right?

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

ParseError: On line 257 of game/script.rpy: say statement does not expect a block.

j "{size=-1}I think that's impressive.  Being on time where ever you go is a very good habit to get into.{/size}"
                                                                                                                 ^

While parsing game/script.rpy.

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

  File "run_game.py", line 62, in main
  File "renpy\main.pyc", line 154, in main
  File "renpy\script.pyc", line 189, in load_script
  File "renpy\script.pyc", line 83, in __init__
  File "renpy\script.pyc", line 109, in load_file
  File "renpy\parser.pyc", line 1216, in parse
  File "renpy\parser.pyc", line 1192, in parse_block
  File "renpy\parser.pyc", line 1175, in parse_statement
  File "renpy\parser.pyc", line 364, in expect_noblock
  File "renpy\parser.pyc", line 337, in error
ParseError: On line 257 of game/script.rpy: say statement does not expect a block.

j "{size=-1}I think that's impressive.  Being on time where ever you go is a very good habit to get into.{/size}"
                                                                                                                 ^

While parsing game/script.rpy.

Ren'Py Version: Ren'Py 4.8.5
That's for every line that's indented. If I go through the entire game and take out the indents, that will fix?

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#9 Post by PyTom »

Skittle Sama wrote:Odd, I still seem to be getting error messages. I made sure that the lines weren't indented after that, but I'm still getting error messages. If I have the input code there, does that mean that all the rest of the game script will have to be be 'un-indented' as well?
I'm not really quite sure I understand what's going on anymore. Can you kick the script over to me via email, and I'll check it out for you?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Skittle Sama
Newbie
Posts: 12
Joined: Sat Apr 23, 2005 1:43 pm
Location: Sarasota, Fl.
Contact:

#10 Post by Skittle Sama »

There you go, I sent it via PM to your inbox.
My comments are a little confusing.

Peewee

#11 Post by Peewee »

Okay, so I cut and pasted PyTom's sample code from above into my script. I can launch the game, but the second I try and input a name when I get to the renpy.input line, the program crashes and says--


I'm sorry, but an exception occured while executing your Ren'Py
script.

TypeError: iterable argument required

The last script statement executed was on line 116 of
game/script.rpy.

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

File "run_game.py", line 61, in main
File "renpy\main.pyc", line 157, in main
File "renpy\main.pyc", line 121, in run
File "renpy\execution.pyc", line 68, in run
File "renpy\ast.pyc", line 222, in execute
File "renpy\python.pyc", line 642, in py_exec_bytecode
File "<none>", line 1, in <module>
File "renpy\exports.pyc", line 142, in input
File "renpy\ui.pyc", line 45, in interact
File "renpy\display\core.pyc", line 658, in interact
File "renpy\display\core.pyc", line 897, in interact_core
File "renpy\display\layout.pyc", line 106, in event
File "renpy\display\layout.pyc", line 106, in event
File "renpy\display\layout.pyc", line 106, in event
File "renpy\display\layout.pyc", line 106, in event
File "renpy\display\layout.pyc", line 106, in event
File "renpy\display\behavior.pyc", line 467, in event
TypeError: iterable argument required

The last script statement executed was on line 116 of
game/script.rpy.


Weird, huh? Any idea what that could mean?

I'd appreciate any help.

Megaman Z
Miko-Class Veteran
Posts: 829
Joined: Sun Feb 20, 2005 8:45 pm
Projects: NaNoRenO 2016, Ren'Py tutorial series
Location: USA
Contact:

#12 Post by Megaman Z »

Peewee wrote:Okay, so I cut and pasted PyTom's sample code from above into my script. I can launch the game, but the second I try and input a name when I get to the renpy.input line, the program crashes and says--


I'm sorry, but an exception occured while executing your Ren'Py
script.

TypeError: iterable argument required

The last script statement executed was on line 116 of
game/script.rpy.


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

File "run_game.py", line 61, in main
File "renpy\main.pyc", line 157, in main
File "renpy\main.pyc", line 121, in run
File "renpy\execution.pyc", line 68, in run
File "renpy\ast.pyc", line 222, in execute
File "renpy\python.pyc", line 642, in py_exec_bytecode
File "<none>", line 1, in <module>
File "renpy\exports.pyc", line 142, in input
File "renpy\ui.pyc", line 45, in interact
File "renpy\display\core.pyc", line 658, in interact
File "renpy\display\core.pyc", line 897, in interact_core
File "renpy\display\layout.pyc", line 106, in event
File "renpy\display\layout.pyc", line 106, in event
File "renpy\display\layout.pyc", line 106, in event
File "renpy\display\layout.pyc", line 106, in event
File "renpy\display\layout.pyc", line 106, in event
File "renpy\display\behavior.pyc", line 467, in event
TypeError: iterable argument required

The last script statement executed was on line 116 of
game/script.rpy.



Weird, huh? Any idea what that could mean?

I'd appreciate any help.
the underlined lines (in the quote box) tell you where to look. since it's "script.rpy", this should be fixable on your end. open it up with SciTE and use the GOTO command to jump to that line. if you can't figure out what to do, then keep asking.

also, I think the code above was supposed to be for showing an example of what would cause an error, if I'm not mistaken...
~Kitsune Zeta

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#13 Post by PyTom »

Peewee:

There was an error in my sample code. I've updated it. Basically, the last parameter must be written length=30, rather than just 30.

We apologize for the inconvenience.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

ShiraiJunichi
Miko-Class Veteran
Posts: 651
Joined: Sat May 21, 2005 12:28 pm
Location: University of Utah
Contact:

#14 Post by ShiraiJunichi »

I'm trying to show some a number variable on the screen with the following statement:

show text "You obtained %(endcounter)d of 5 endings!"

But the program ends up not replacing %(endcounter)d with the value of the variable, but displays the text exactly as shown...
It works fine in dialog, but how can I get it to work with a show text statement?

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#15 Post by PyTom »

You can't, since show text isn't as magical as a say statement. You'll have to write something like:

Code: Select all

$ renpy.show(('text', "You obtained %(endcounter)d of 5 endings!" % globals()))
instead. (Not tested.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users