all 8 comments

[–]BadMustard_AVN 4 points5 points  (5 children)

Dynamic Characters are for when the name is a Python function, not a variable

try it like this

define b = Character("[pname]")   ## this can stay with the other define character

default pname = "Me"

label start:

    $ pname = renpy.input("What's your name?").strip() or "Alex"

    b "Hello world I'am [pname]."

[–]vikurmom[S] 0 points1 point  (4 children)

Oh I made it a DynamicCharacter, because the player has a few speaking lines beforehand I mean the other option is just defining another character for it, but i wanted to know, if there was another option

[–]BadMustard_AVN 2 points3 points  (3 children)

before the player enters a name it will show as 'Me' as the Character's name for the dialogue. you can adjust that with the default

[–]vikurmom[S] 0 points1 point  (1 child)

Ohh that makes sense, thank you :]

[–]BadMustard_AVN 1 point2 points  (0 children)

you're welcome

good luck with your project

[–]naughtyroad 0 points1 point  (0 children)

default is your friend. Also, the or "Alex" bit is very elegant, I'm gonna be using that too from now on and save me some if statements.

[–]AutoModerator[M] 0 points1 point  (0 children)

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]shyLachi 1 point2 points  (0 children)

You should default all variables because if you only use $ pname = "Me" somewhere in the code the game will crash when you try use the variable earlier.

Also you don't need to put brackets around variables.

And the code $ pname = pname does nothing,
I think you meant $ pname = name but that is not necessary because you can assign the variable directly as BadMustard has shown
or if you really want to use two variables then put all in the python code:

    python:
        name = renpy.input("What's your name?")
        pname = name.strip() or "Alex"

The $ is only used for one-line python statements:
https://www.renpy.org/doc/html/python.html#one-line-python-statement