Using hyperlinks as buttons [SOLVED]
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.
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.
Using hyperlinks as buttons [SOLVED]
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.
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.
- 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
You can change config.hyperlink callback to do what you want. Something like:
Would let you write:
But there would be the problem that clicking outside a hyperlink would continue the game via the next line.
Code: Select all
init python:
def hyperlink_callback(l):
renpy.jump(l)
config.hyperlink_callback = hyperlink_callback
Code: Select all
"Would you like to go to {a=jail}jail{/a}?"
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom
Re: Using hyperlinks as buttons
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:
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.
Code: Select all
$ renpy.show_screen(...)
$ result = ui.interact()
- 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
Something like:
Will cause the value of the hyperlink to be returned from ui.interact.
Code: Select all
init python:
def hyperlink_callback(l):
return l
config.hyperlink_callback = hyperlink_callback
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom
Re: Using hyperlinks as buttons
Omg, I can't believe it was so easy. Thank you man, and congratulations for Ren'Py: it's wonderful!
Who is online
Users browsing this forum: Google [Bot]