[Solved]How to create customized 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
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

[Solved]How to create customized tags?

#1 Post by bonnie_641 »

Good afternoon everyone. I have searched everywhere and I don't understand how to create a tag associated with playing music or sound when clicking on the text.

Example:
{play="ex.mp3"}example sound{/play} #as it is not defined it generates error.

Thanks in advance
Last edited by bonnie_641 on Sat Nov 19, 2022 1:36 pm, edited 1 time in total.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

enaielei
Veteran
Posts: 293
Joined: Fri Sep 17, 2021 2:09 am
Organization: enaielei
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: How to create customized tags?

#2 Post by enaielei »

You can probably use hyperlink handlers.
The following is an example (untested).

Code: Select all

init python:
    config.hyperlink_handlers["play"] = renpy.play

label start:
    "{a=play:sound.mp3}click to play sound{/a}"

User avatar
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

Re: How to create customized tags?

#3 Post by bonnie_641 »

Thank you for taking the time and patience to answer my question.
enaielei wrote:

Code: Select all

init  python:

    def play(tag, argument, contents):
        renpy.play(argument)
        return contents

    config.custom_text_tags["play"] = play
This code is very useful to me. I tested it in the dictionary project and it works :D and even gives a very curious sound effect in the pronunciation of the words (futuristic style).
enaielei wrote: Fri Nov 18, 2022 11:49 pm You can probably use hyperlink handlers.
The following is an example (untested).

Code: Select all

init python:
    config.hyperlink_handlers["play"] = renpy.play

label start:
    "{a=play:sound.mp3}click to play sound{/a}"
You gave me a good idea to use the two codes.
I reiterate my thanks to you. You are an angel.
Topic solved. :D
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

Post Reply

Who is online

Users browsing this forum: No registered users