renpy/doc/cookbook/Conditional Hyperlinks

From Ren'Py

Jump to: navigation, search

Conditional Hyperlinks

Maybe you want to be able to turn hyperlinks on or off for some reason. Putting this code into a Python init block will show hyperlinks only when persistent.hyperlinks_on is True:

    import re
    expr = re.compile(r'{a=.*?}|{/a}')
    def remove_hyperlinks(input):
        global expr
        if persistent.hyperlinks_on:
            return input
        else:
            return re.sub(expr, "", input)

    config.say_menu_text_filter = remove_hyperlinks

Of course, by tweaking the regular expression and using naming conventions for hyperlink labels, it's possible to filter only certain hyperlinks while leaving others in. This, for example, will only suppress hyperlinks beginning with "opt_":


    expr = re.compile(r'{a=opt_.*?}|{/a}')
Personal tools