[SOLVED] Execute function on custom tags

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
cimokudo
Newbie
Posts: 6
Joined: Tue Jul 24, 2018 1:34 am
Completed: ATM_OS a RenPy based ATM Simulator
Projects: WinFn, GoTran, RenLoop
Deviantart: cimokudo
Github: cimo95

[SOLVED] Execute function on custom tags

#1 Post by cimokudo »

I have read about custom_tags and how to use it.
But instead of styling the tagged text, i want to make a function work while clicking a tagged text, like what anchor / {a=}{/a} tag work.

From the example given in Custom Text Tags section, in Ren'Py Documentation, it just show how to use custom_tags for styling use.

I want to show modal screen contains information from argument of the tagged text.

for example :

Code: Select all

 cimo "What? I can't believe you love {pop='It is a Japanese genre of erotic video game.'}eroge{/pop} so much." 
While "eroge" clicked, it will pop modal screen showing the argument as content.

Code: Select all

init python:
    def popinfo(tag, argument, contents):
        Show("alert",title=contents,text=argument)()
        
    config.custom_text_tags["pop"] = popinfo

screen alert(title, text):
    modal True
    zorder 200
    style_prefix "confirm"
    add "gui/overlay/confirm.png"
    frame:
        vbox:
            xalign .5
            yalign .5
            spacing 15
            text "{size=30}[title]{/size}"
            text "{size=15}[text]{/size}"
            hbox:
                xalign 0.5
                textbutton "OK" action Hide("alert")
Sorry if the code above error, im not on my working pc right now.
Last edited by cimokudo on Wed Dec 07, 2022 7:32 pm, edited 1 time in total.
Error : Unable to fetch user signature.

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

Re: Execute function on custom tags

#2 Post by Ocelot »

You can use {a} tag for that.

Code: Select all

init python:
    def handle_alert_with_parameters(arg):
        param = arg.split('|')
        renpy.show_screen("alert", *param)

    config.hyperlink_handlers['alert'] = handle_alert_with_parameters

# . . . 

cimo "What? I can't believe you love {a=alert:eroge|It is a Japanese genre of erotic video game.}eroge{/a} so much." 
< < insert Rick Cook quote here > >

User avatar
cimokudo
Newbie
Posts: 6
Joined: Tue Jul 24, 2018 1:34 am
Completed: ATM_OS a RenPy based ATM Simulator
Projects: WinFn, GoTran, RenLoop
Deviantart: cimokudo
Github: cimo95

Re: Execute function on custom tags

#3 Post by cimokudo »

Ocelot wrote: Tue Dec 06, 2022 8:35 pm You can use {a} tag for that.

Code: Select all

init python:
    def handle_alert_with_parameters(arg):
        param = arg.split('|')
        renpy.show_screen("alert", *param)

    config.hyperlink_handlers['alert'] = handle_alert_with_parameters

# . . . 

cimo "What? I can't believe you love {a=alert:eroge|It is a Japanese genre of erotic video game.}eroge{/a} so much." 
Sweet!, i'll try it later. Thanks !
Error : Unable to fetch user signature.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]