Coding Dialogue Statements easier!

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Message
Author
initialzero
Regular
Posts: 27
Joined: Fri Jul 08, 2016 6:53 am
Contact:

Coding Dialogue Statements easier!

#1 Post by initialzero »

Hi!

I am using ATOM to code the blabla statements for the lines.

Is there any easier way or have a macro to mark the line and it will be automatically added with "\"...\"" ??? (my script is finished and I have to add for each line the statements. It is really annoying and time consuming!)

"\"text bla blabla\"" >>> "\"...\"" for each line?

Sorry for this beginner question but I am still a beginner using coding text editor.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Coding Dialogue Statements easier!

#2 Post by namastaii »

Is this so you can include quotation marks in your script? Any reason for it?
I guess you could use the "look for" at the bottom in atom (or by pressing ctrl+F) and type in "" so you know where you've put the extra quotations and in the second box type "\" and press "replace"

initialzero
Regular
Posts: 27
Joined: Fri Jul 08, 2016 6:53 am
Contact:

Re: Coding Dialogue Statements easier!

#3 Post by initialzero »

I have about 10.000 lines to add the quotation marks but I dont wanna add it manually. Is there an easy way to do it?

User avatar
Kia
Eileen-Class Veteran
Posts: 1039
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Coding Dialogue Statements easier!

#4 Post by Kia »

you can write a macro with AutoIt for such a task, though that still requires lots of manual selection of each line and pressing a key

drKlauz
Veteran
Posts: 239
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Coding Dialogue Statements easier!

#5 Post by drKlauz »

Or you can write python or even RenPy script what will load lines from file, modify lines and save lines to new file.
P.S.: Something like:

Code: Select all

label start:
  python:
    ## load lines, file.txt must be in project directory
    with open(config.basedir+'\\file.txt','r') as f:
      lines=f.read().split('\n')
    ## modify lines
    for n,line in enumerate(lines):
      ## modify line as you see fit here
      line=line.replace('"',"'")
      ## now store it for later saving
      lines[n]=line
    ## save result file to project directory
    with open(config.basedir+'\\file_result.txt','w') as f:
      f.write('\n'.join(lines))
  'Done'
  return
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: Coding Dialogue Statements easier!

#6 Post by Tayruu »

Are you specifically trying to wrap dialogue in quote-marks, or is there a different use to it? Because you can add quote marks around text by using prefix/suffix arguments in Character() statements --

Code: Select all

Character(name, what_prefix=u"“", what_suffix="”")

initialzero
Regular
Posts: 27
Joined: Fri Jul 08, 2016 6:53 am
Contact:

Re: Coding Dialogue Statements easier!

#7 Post by initialzero »

Tayruu wrote: Fri Sep 06, 2019 8:46 pm Are you specifically trying to wrap dialogue in quote-marks, or is there a different use to it? Because you can add quote marks around text by using prefix/suffix arguments in Character() statements --

Code: Select all

Character(name, what_prefix=u"“", what_suffix="”")
OmG!! I think this could be the most usable way to wrap the text! I will try it out!! Thank you!!!!!

initialzero
Regular
Posts: 27
Joined: Fri Jul 08, 2016 6:53 am
Contact:

Re: Coding Dialogue Statements easier!

#8 Post by initialzero »

I tried this code:

Code: Select all

define s = Character(_("Sylvie"), color="#c8ffc8", what_prefix=""", what_suffix=""")
define m = Character(_("Me"), color="#c8c8ff", what_prefix=""", what_suffix=""")


label start:

   
    play music "illurock.opus"

    scene bg lecturehall
    with fade

    s It's only when I hear the sounds of shuffling feet and supplies being put away that I realize that the lecture's over.


But I get an error! What is wrong with the what_prefix and suffix?

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Coding Dialogue Statements easier!

#9 Post by namastaii »

You have three double-quotation marks """ which doesn't work. You need to change that to two.

Oh I see what you were trying to do. I don't know, could you show the error?

User avatar
SleepKirby
Veteran
Posts: 255
Joined: Mon Aug 09, 2010 10:02 pm
Projects: Eastern Starlight Romance, Touhou Mecha
Organization: Dai-Sukima Dan
Location: California, USA
Contact:

Re: Coding Dialogue Statements easier!

#10 Post by SleepKirby »

Code: Select all

what_prefix="""
It sounds like you're trying to make the first and third " be the start and end of a Python string, and the second " be the actual what_prefix, but Python can't figure that out. If you have two " in a row, Python thinks that's a string with nothing in it. And actually, if you have three " in a row, Python thinks that's the start of a triple-quoted string.

There are a few ways to write a Python string containing a quotation mark.

1. Surround the " with single quotes, '. Python strings can be defined using either single or double quotes.

Code: Select all

what_prefix='"'
2. Use a backslash.

Code: Select all

what_prefix="\""
3. Use directional quote characters, as Tayruu did. In Python 2 (which Ren'Py uses), these characters are not really supported by regular strings, so the u specifies that it's a Unicode string. (TBH, I don't know if the u is strictly needed here, but I don't think it hurts.) Anyway, note that depending on your game's font, this may affect how the quote marks look in-game. If you prefer how the directional quotes look, then use this. If you prefer the non-directional ones, use method 1 or 2.

Code: Select all

what_prefix=u"“", what_suffix=u"”"

initialzero
Regular
Posts: 27
Joined: Fri Jul 08, 2016 6:53 am
Contact:

Re: Coding Dialogue Statements easier!

#11 Post by initialzero »

I still got an error the syllables are missing. Could it be that the what_prefix is on the wrong place?

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Coding Dialogue Statements easier!

#12 Post by namastaii »

Code: Select all

define s = Character(_("Sylvie"), color="#c8ffc8", what_prefix='"', what_suffix='"')
worked just fine for me (a double quote within two single quotes)

initialzero
Regular
Posts: 27
Joined: Fri Jul 08, 2016 6:53 am
Contact:

Re: Coding Dialogue Statements easier!

#13 Post by initialzero »

I always get this error message

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/script.rpy", line 23: is not terminated with a newline. (Check strings and parenthesis.)
(Perhaps you left out a ' at the end of the first line.)
        s I've had a lot of other thoughts on my mind...thoughts that culminate in a question.

Ren'Py Version: Ren'Py 7.3.2.320
Sat Sep 14 10:08:26 2019

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Coding Dialogue Statements easier!

#14 Post by namastaii »

You still have to put quotations around the strings in the dialogue though. Or the script can't read them. The suffixes and such are just to add to it when it plays in-game. You can't use it to replace actual syntax

initialzero
Regular
Posts: 27
Joined: Fri Jul 08, 2016 6:53 am
Contact:

Re: Coding Dialogue Statements easier!

#15 Post by initialzero »

namastaii wrote: Sat Sep 14, 2019 6:30 pm You still have to put quotations around the strings in the dialogue though. Or the script can't read them. The suffixes and such are just to add to it when it plays in-game. You can't use it to replace actual syntax
oh! I just thought that we could save time putting the strings :?

Post Reply

Who is online

Users browsing this forum: No registered users