Passing control to a label via hyperlink?
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.
Passing control to a label via hyperlink?
What the topic says. I'm trying to pass control of the game to another label after clicking a hyperlink. I found this old thread where they tried to do that, and the first solution works like a charm, but it also makes hyperlinks lose their style (You can still click them, but they look just like any other text).
So my question is of course: Is there any way to make control of the game pass to another label after clicking a hyperlink (Instead of getting back to the place where it was clicked in the first place after reaching a return statement)? Or at the very least how to use the code in that old thread without the hyperlink style changing?
Thanks in advance.
So my question is of course: Is there any way to make control of the game pass to another label after clicking a hyperlink (Instead of getting back to the place where it was clicked in the first place after reaching a return statement)? Or at the very least how to use the code in that old thread without the hyperlink style changing?
Thanks in advance.
- 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: Passing control to a label via hyperlink?
Check out:
http://www.renpy.org/doc/html/style_pro ... properties
You can have the clicked function handle jumping.
http://www.renpy.org/doc/html/style_pro ... properties
You can have the clicked function handle jumping.
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: Passing control to a label via hyperlink?
Sorry but, is there any function/value that would help me achieve that already included? Or do I need to create a special function for it?
- 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: Passing control to a label via hyperlink?
You'd have to create a special function. Something like:
Code: Select all
init python:
def hyperlink_styler(anchor):
return style.hyperlink
def hyperlink_clicked(anchor):
renpy.jump(anchor)
def hyperlink_hovered(anchor):
return None
style default:
hyperlink_functions (hyperlink_styler, hyperlink_clicked, hyperlink_hovered)
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: Passing control to a label via hyperlink?
Worked perfectly, thanks!
An addition for anyone looking at this topic, the styling is pretty simple. Following the example given before you'd only need to either name a style "hyperlink" or replace "hyperlink" in return style.hyperlink with whatever you need.
This way the links would look like big red words.
Thanks again!
An addition for anyone looking at this topic, the styling is pretty simple. Following the example given before you'd only need to either name a style "hyperlink" or replace "hyperlink" in return style.hyperlink with whatever you need.
Code: Select all
init python:
style.hyperlink = Style(style.default)
style.hyperlink.color = "#f00"
style.hyperlink.size = 42
def hyperlink_styler(anchor):
return hyperlink
def hyperlink_clicked(anchor):
renpy.jump(anchor)
def hyperlink_hovered(anchor):
return None
style default:
hyperlink_functions (hyperlink_styler, hyperlink_clicked, False)Thanks again!
- octacon100
- Regular
- Posts: 163
- Joined: Thu Sep 12, 2013 11:23 pm
- Projects: Regeria Hope
- Organization: Golden Game Barn
- IRC Nick: Octacon100
- Location: Boston, MA
- Contact:
Re: Passing control to a label via hyperlink?
Thanks for that, it's a really big help!
Also, if anyone wants to just apply it to text in a certain screen, like the nvl screen, you can do something like this:
That code also shows how to have the text change color when you hover over it. Hope that helps someone.
Also, if anyone wants to just apply it to text in a certain screen, like the nvl screen, you can do something like this:
Code: Select all
## Need to set up the hyperlink style first.
init -1 python:
style.hyperlink = Style(style.nvl_dialogue)
style.hyperlink.color = "#c33"
style.hyperlink.hover_color = "#c66"
style.hyperlink.underline = True
#style.hyperlink.size = 42
def hyperlink_styler(anchor):
return style.hyperlink
def hyperlink_clicked(anchor):
renpy.jump(anchor)
def hyperlink_hovered(anchor):
return None
-snip til you get to the text you want to change the hyperlink functions for-
text what id what_id hyperlink_functions (hyperlink_styler, hyperlink_clicked, False)
Who is online
Users browsing this forum: Bing [Bot], zyric

