[Solved] Inline NVL Clear?

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
SinSisters
Regular
Posts: 97
Joined: Sat Sep 20, 2014 11:07 am
Completed: The Spanish Privateer
Projects: The Spanish Privateer
Tumblr: sinsisters
itch: sinsisters
Location: Canada
Contact:

[Solved] Inline NVL Clear?

#1 Post by SinSisters »

I know that Ren'Py has the monologue mode {clear} tag, but I was wondering if there was something equivalent that could work for a single line. For example, if

Code: Select all

exstr = "{clear}This is a simple example.{clear}The text is very long."
narrator(exstr)
With the hope that the output would be the same as:

Code: Select all

"""
{clear}

This is a simple example.

{clear}

The text is very long.
"""
I assumed the next best thing would be a custom text tag. However, any attempts at changing the nvl_list result in the function being called too early/unexpected behaviour, resulting in the NVL in the text above the line with the text tag getting cleared every line.
Last edited by SinSisters on Wed Dec 14, 2022 3:50 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2445
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Inline NVL Clear?

#2 Post by Ocelot »

nvl clear is supposed to be it's own statement. Monologue mode has this pseudo-tag because it is broken down into separate statements internally anyway, and it does make sense to not force developer to break monologue mode every time you need to clear the screen.

A say statement is a single statement. You can put clear statement before or after it, but not in the middle. You cannot do that with tags, because tags are evalueated early and often, so they cannot have any side effects.

You can pass your line to some function, which will separate sentences and tags, transforming single string into a list of strings, and some other type denoting a clear command. Then you can pass it to some other funtion, which will execute all list elements in order, saying sentences and clearing screen when it is needed.
< < insert Rick Cook quote here > >

User avatar
SinSisters
Regular
Posts: 97
Joined: Sat Sep 20, 2014 11:07 am
Completed: The Spanish Privateer
Projects: The Spanish Privateer
Tumblr: sinsisters
itch: sinsisters
Location: Canada
Contact:

Re: Inline NVL Clear?

#3 Post by SinSisters »

Thanks for the clarification, I used ZX and split the string with that sequence. Works well!

Post Reply

Who is online

Users browsing this forum: LemonaBittera, Ocelot