Using hyperlinks as buttons [SOLVED]

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
Paulaner
Newbie
Posts: 20
Joined: Thu Nov 04, 2010 6:28 am
Contact:

Using hyperlinks as buttons [SOLVED]

#1 Post by Paulaner » Thu Nov 04, 2010 6:40 am

Hi everyone. I'm new to Ren'Py and to the forums, so I apologize if the matter has already been discussed.

I know that hyperlinks should not be used to control the game's logic, because they transfer control to a new context, and so on.
But that's what I have to do: using hyperlinks as buttons, indicating a return value and, most important, terminating the current interaction, just as if I clicked a regular widget.
My game will be heavily text-based, so directly clicking on words will be my main control-flow tool.
Suggestions?

Thanx a lot.
Last edited by Paulaner on Sat Nov 06, 2010 3:49 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Using hyperlinks as buttons

#2 Post by PyTom » Thu Nov 04, 2010 9:33 am

You can change config.hyperlink callback to do what you want. Something like:

Code: Select all

init python:
    def hyperlink_callback(l):
        renpy.jump(l)

    config.hyperlink_callback = hyperlink_callback
Would let you write:

Code: Select all

"Would you like to go to {a=jail}jail{/a}?"
But there would be the problem that clicking outside a hyperlink would continue the game via the next line.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Paulaner
Newbie
Posts: 20
Joined: Thu Nov 04, 2010 6:28 am
Contact:

Re: Using hyperlinks as buttons

#3 Post by Paulaner » Thu Nov 04, 2010 9:49 am

Is there an alternative to jumping to a label? I'm building a complex screen user interface made up of text (with hyperlinks), buttons and other widgets. I show the screen and I wait for an interaction:

Code: Select all

$ renpy.show_screen(...)
$ result = ui.interact()
Buttons in the screen terminate the interaction and return a result (through clicked=ui.return(..) ). I'd like hyperlinks to do the same. I don't know how to simulate this behavior in the hyperlink callback function.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Using hyperlinks as buttons

#4 Post by PyTom » Thu Nov 04, 2010 9:56 am

Something like:

Code: Select all

init python:
    def hyperlink_callback(l):
         return l
    config.hyperlink_callback = hyperlink_callback
Will cause the value of the hyperlink to be returned from ui.interact.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Paulaner
Newbie
Posts: 20
Joined: Thu Nov 04, 2010 6:28 am
Contact:

Re: Using hyperlinks as buttons

#5 Post by Paulaner » Thu Nov 04, 2010 9:59 am

Omg, I can't believe it was so easy. Thank you man, and congratulations for Ren'Py: it's wonderful!

Post Reply

Who is online

Users browsing this forum: Google [Bot]