Copying the ingame text to the clipboard?

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
nevarran
Newbie
Posts: 6
Joined: Tue Jan 02, 2018 5:51 am
Contact:

Copying the ingame text to the clipboard?

#1 Post by nevarran »

Hi,
I'm making a small VN, and I had a few people asking me if I can make it so that they can copy the text while playing the game and then paste it in Google Translate or something. Is that possible? Like a adding a button that copies the current text and adds it to the clipboard.
I think it will be a very useful function for everyone who's English is not good enough.
Thanks.

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Copying the ingame text to the clipboard?

#2 Post by IrinaLazareva »

somewhere in the script:

Code: Select all

init python:
    import pygame.scrap
    def scrubs(what):
        pygame.scrap.put(pygame.SCRAP_TEXT, what.encode("utf-8"))
        renpy.notify("The text is now on the clipboard.")
and then just add to the say() screen:

Code: Select all

screen say(who, what):

    ###<body of the screen>
    
    if what:
        textbutton _('Copy into the clipboard') style 'quick_button' action Function(scrubs, what) at right
https://www.pygame.org/docs/ref/scrap.h ... .scrap.put

nevarran
Newbie
Posts: 6
Joined: Tue Jan 02, 2018 5:51 am
Contact:

Re: Copying the ingame text to the clipboard?

#3 Post by nevarran »

IrinaLazareva wrote: Sat Oct 05, 2019 4:01 pm somewhere in the script:
...
Thank you, works like a charm. Much appreciated.

Post Reply

Who is online

Users browsing this forum: Google [Bot]