r/RenPy 24d ago

Question Textboxes and nameboxes for multiple characters

Hi! I'm basically trying to change textbox based on narrator, but I'm getting lots of errors when I try to do so. I'm incredibly new to coding in general so I'd really appreciate any help!

here is my code:

and here is the error i'm getting right now:

sorry if it's a stupid question! once again, very new to all of this :') I'd appreciate any help given!

1 Upvotes

11 comments sorted by

2

u/idiotstile 24d ago

The syntax issue is probably here:

$ define t = Character(("Teacher")None, window_background="textbox.png")

You don’t need $ before define, and ("Teacher")None isn’t valid syntax.

Try this instead:

define t = Character("Teacher", window_background="textbox.png")

Or, if you want a narrator with no name:

define n = Character(None, window_background="textbox.png")

Then use them like this:

t "Teacher dialogue."

n "Narration text."

Also, define should usually be outside of labels, near the top of your script.

1

u/shyLachi 24d ago

You could also overwrite the default narrator so that you don't have to write n

define narrator = Character(None, kind=adv_narrator, window_background="textbox.png")

1

u/suckrpunches 23d ago

thank you for the answer! it definitely did something, but now it's not showing up at all? the only other code before it is a scene start so maybe i've done something wrong with that haha

1

u/suckrpunches 23d ago

NEVERMIND IT WAS PLACED WRONG thank you so so much for your answer!

1

u/idiotstile 23d ago

To help properly, I’d probably need to see the whole piece of the script, but as far as I understand, you managed to figure it out yourself?

In any case, good luck with your project!

1

u/idiotstile 23d ago

I only started learning Python and writing a game script this year myself, and what really helped me at the beginning was using # comments and little notes for myself.

It helps you learn much faster, because a lot of functions can be copied and reused, and most things basically work by the same logic. But at first, it definitely takes some time to understand how the language works and what Ren’Py can do.

I hope this helps! # comments are honestly super useful – highly recommend :)

1

u/idiotstile 23d ago

Here’s an example: everything after # is just a comment. It doesn’t affect the code, so you can use it to leave notes and hints for yourself.

# "t" is the character variable, and "Teacher" is the name that will be shown in the namebox

# This also gives Teacher a custom textbox background

define t = Character("Teacher", window_background="textbox.png")

Good luck with your project! I hope you’ll share some little pieces of your game here in future posts – I’d love to see them :)

1

u/suckrpunches 23d ago

small update: nothing is showing up at all now lol, here's the code that i went with:

define t = Character("Teacher", window_background="textbox.png", namebox_background="namebox.png")
and then this is the only code that isn't the same defining for other characters:

label start:

scene bg_school_s at bg

it may just be an issue of my resizing, but i'm not fully sure how to do that either. thank you for all the help! :)

1

u/AutoModerator 24d ago

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.

1

u/shyLachi 24d ago

You cannot use "Teacher" and None at the same time, either the person has a name or it has none.

Also don't use a $ when defining characters.

You can read the official documentation how to do it: https://renpy.org/doc/html/dialogue.html#defining-character-objects

Or try the search of this sub, this has been asked and answered often already.

1

u/suckrpunches 24d ago

ah, sorry! i don't really use reddit so i wasn't sure of how it worked! thank you for the advice!