Having the textbox change midgame

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
Alphonse
Regular
Posts: 105
Joined: Tue Aug 26, 2008 7:32 pm
Contact:

Having the textbox change midgame

#1 Post by Alphonse »

I looked a lot and I probably wasn't typing the right keywords because I couldn't find anything. Is changing the textbox at certain places in the game/script possible? I hope this isn't a stupid question and I'm sorry if I'm not being clear.

User avatar
usul
Veteran
Posts: 415
Joined: Mon Oct 29, 2007 12:35 pm
Projects: Teachings of the Buddha, System-Addict, Generation XxX
Location: Quebec
Contact:

Re: Having the textbox change midgame

#2 Post by usul »

The text box is set up in the options file. If you can change it mid-game I don't know how.
"The universe is non-simultaneously apprehended"
— Buckminster Fuller

JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Having the textbox change midgame

#3 Post by JQuartz »

Alphonse wrote:Is changing the textbox at certain places in the game/script possible?
It depends, what do you want to change?
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

Dusty
Regular
Posts: 126
Joined: Fri Jul 25, 2008 11:51 pm
Contact:

Re: Having the textbox change midgame

#4 Post by Dusty »

What you could do is use Style Customization to create a style that inherits from style.say_dialogue for each different style that you want.

Then, say you created style.say_dialogue_act1 and style.say_dialogue_act2. One way you could make it so that after a certain point the dialogue box changes is to define each character twice - once for act 1 and once for act 2.

For the Character for act 1, you set what_style=style.say_dialogue_act1,
and for the Character for act 2, you set what_style=style.say_dialogue_act2.

Then, for all the lines in act 1, you could, for example, say:
eileen_act1 "Hello!"
lucy_act1 "Hi."

and then in act 2:
eileen_act2 "I have slain the dragon."
dragon_act2 ":("

There might be another way hidden deep in the depths of the config file, but this'll probably work if you can figure out how to customize styles using the Style function.

User avatar
PyTom
Ren'Py Creator
Posts: 16082
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:

Re: Having the textbox change midgame

#5 Post by PyTom »

Perhaps another way would be to use a ConditionSwitch as the value of style.window.background. This would let one change the background based on a variable.

Code: Select all

init python:
    style.window.background = ConditionSwitch(
        "frame == 1", Frame("frame_1.png", 10, 10),
        "frame == 2", Frame("frame_2.png", 10, 10),
        )

label start:

    $ frame = 1

    "This uses the first frame style."

    $ frame = 2
   
    "This uses the second frame style."
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

Alphonse
Regular
Posts: 105
Joined: Tue Aug 26, 2008 7:32 pm
Contact:

Re: Having the textbox change midgame

#6 Post by Alphonse »

@JQuartz: Just the appearance.

@Dusty: ? That sounds a little complicated. So every time I had a scene with the different textboxes. I'd have to use different Character things? But this would be useful, if I didn't want to change textboxes. I'm sure this will come in handy eventually!

@PyTom: This ConditionSwitch of yours...how long has this been in existence? :shock: I looked it up just now and, oh my God, if this does what I think it does, how was I living without this?! I think I'm in love. Is it legal in the States for a minor to marry a piece of code?

Thank you all for your help and for all of you not going into confusing programmer-talk! -tears of joy-

RayRayTea
Regular
Posts: 69
Joined: Thu May 07, 2009 4:16 pm
Projects: The Stolen Diamond Ring (a mystery VN)
Contact:

Re: Having the textbox change midgame

#7 Post by RayRayTea »

I'm trying to achieve something similiar but even after reading all the posts in this and a few relevant threads I'm still not able to make a paragraph with alignment set to centered sit in the middle of the dialogue box.

So far I found out how to have the text centered in the middle of the screen: by using the "centered" command before the text. This is basically way above the dialogue window background + it also makes the dialogue window itself disappear.

For now I'm just trying to change the appearance of the text, not the actual background / frame around it.

In the project I'm working on it should be like this:
Image
Image

So the question is: how do I align a block of text centrally within the dialogue box?
nekomura games
Princess Battles, a card-based stat raising sim

JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Having the textbox change midgame

#8 Post by JQuartz »

RayRayTea wrote:how do I align a block of text centrally within the dialogue box?
This should work:

Code: Select all

init:
    $ narrator=Character(None,show_say_vbox_properties=dict(xalign=0.5),what_text_align=0.5)
label start:
    "Lorem ipsum dolor sit amet\nsadipscing ialura est.\nDolr sit, manea tanea."
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

RayRayTea
Regular
Posts: 69
Joined: Thu May 07, 2009 4:16 pm
Projects: The Stolen Diamond Ring (a mystery VN)
Contact:

Re: Having the textbox change midgame

#9 Post by RayRayTea »

Thanks, that's exactly what I was looking for.
nekomura games
Princess Battles, a card-based stat raising sim

User avatar
SeventhHeart
Newbie
Posts: 19
Joined: Mon May 08, 2017 8:01 pm
Projects: Eternal Hour, Quantum Magica
Organization: Seventh Heart Studios
Soundcloud: seventh-heart-studio
Location: Romania
Contact:

Re: Having the textbox change midgame

#10 Post by SeventhHeart »

Managed to implement this, super neat feature! :D

Post Reply

Who is online

Users browsing this forum: Google [Bot]