How to output formatted text from file to a ren'py screen?

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
henvu50
Regular
Posts: 92
Joined: Wed Aug 22, 2018 1:22 am
Contact:

How to output formatted text from file to a ren'py screen?

#1 Post by henvu50 » Fri Oct 25, 2019 10:48 pm

How do you output formatted text from file to a ren'py screen?

henvu50
Regular
Posts: 92
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: How to output formatted text from file to a ren'py screen?

#2 Post by henvu50 » Sat Oct 26, 2019 5:03 pm

Bump, anyone?

I want to know if Ren'py can print out text from a text file onto a screen in ren'py.

User avatar
Alex
Lemma-Class Veteran
Posts: 2317
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: How to output formatted text from file to a ren'py screen?

#3 Post by Alex » Sat Oct 26, 2019 5:58 pm


User avatar
xavimat
Eileen-Class Veteran
Posts: 1433
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: How to output formatted text from file to a ren'py screen?

#4 Post by xavimat » Sun Oct 27, 2019 3:44 am

Your question includes some different things.

- I use codecs.open to open/write utf-8 text files to/from renpy.
- you can store that data in variables, and use that variables to show their content in renpy.
- formatting text is another matter, you have in renpy text tags, styles, properties... It depends if you are using the text in dialogues or screens.

And one more thing:
Probably you don't need to do that. If you tell us what do you want to achieve, we'll try to suggest a better method.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

henvu50
Regular
Posts: 92
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: How to output formatted text from file to a ren'py screen?

#5 Post by henvu50 » Sun Oct 27, 2019 5:24 pm

xavimat wrote:
Sun Oct 27, 2019 3:44 am
Your question includes some different things.
- I use codecs.open to open/write utf-8 text files to/from renpy.
- you can store that data in variables, and use that variables to show their content in renpy.
Hi, thanks for the response. I will use codecs.open, that's helpful.
xavimat wrote:
Sun Oct 27, 2019 3:44 am
- formatting text is another matter, you have in renpy text tags, styles, properties... It depends if you are using the text in dialogues or screens.
If you tell us what do you want to achieve, we'll try to suggest a better method.
I have a whole bunch of RTF files of text that's formatted with bold, underline, italic, even including some tables. Instead of copy & pasting each of these into an RPY file, which would involve lots of extra formatting via text tags, styles, properties, etc, it would be easier to simply just output the contents of the RTF file with its own formatting.

Basically I'd rather do all the formatting of text in a separate program, which is faster than formatting in ren'py, then save it in a text, rtf or word document, then print/output that out in ren'py using codecs.open or something similar.

drKlauz
Regular
Posts: 166
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: How to output formatted text from file to a ren'py screen?

#6 Post by drKlauz » Sun Oct 27, 2019 5:59 pm

I guess best approach would be writing conversion tool or even conversion function to be used by game itself, what will read RTF/HTML file, parse it and convert it into stream of RenPy text+tags, converting tables and images would be bit harder, but doable.
But that is reasonably complex task, so you either need skill or money to get it done.

henvu50
Regular
Posts: 92
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: How to output formatted text from file to a ren'py screen?

#7 Post by henvu50 » Sun Oct 27, 2019 7:04 pm

drKlauz wrote:
Sun Oct 27, 2019 5:59 pm
I guess best approach would be writing conversion tool or even conversion function to be used by game itself, what will read RTF/HTML file, parse it and convert it into stream of RenPy text+tags, converting tables and images would be bit harder, but doable.
But that is reasonably complex task, so you either need skill or money to get it done.
Looks like I'll have to manually copy & paste it, then re-do all the formatting. If I find a better solution I'll share it here.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1433
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: How to output formatted text from file to a ren'py screen?

#8 Post by xavimat » Mon Oct 28, 2019 3:51 pm

henvu50 wrote:
Sun Oct 27, 2019 5:24 pm

I have a whole bunch of RTF files of text that's formatted with bold, underline, italic, even including some tables. Instead of copy & pasting each of these into an RPY file, which would involve lots of extra formatting via text tags, styles, properties, etc, it would be easier to simply just output the contents of the RTF file with its own formatting.

Basically I'd rather do all the formatting of text in a separate program, which is faster than formatting in ren'py, then save it in a text, rtf or word document, then print/output that out in ren'py using codecs.open or something similar.
WoW! That's a lot of work, and very complex. Specially with tables.
Have you alredy read the rtf specifications? You have many things to understand.
I've made renpy programs that output files in rtf, latex and html formats, so I know it's not easy, but I've never tried to do a renpy program able to *read* those files. That would be insane. Rtf has no utf-8 codification, so it's a very heavy format when using text with non-ascii characters.
There are converters (maybe rtf to html) that maybe produce a file easier to understand by renpy, but in any case, you have a lot to do.

EDIT: There are some libraries that claim to parse rtf files using python. Never used them myself but maybe you can try some of them inside renpy.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Andredron, Google [Bot]