Page 1 of 1
Passing control to a label via hyperlink?
Posted: Sat May 09, 2015 11:45 pm
by FamuFamu
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.
Re: Passing control to a label via hyperlink?
Posted: Sun May 10, 2015 12:00 am
by PyTom
Check out:
http://www.renpy.org/doc/html/style_pro ... properties
You can have the clicked function handle jumping.
Re: Passing control to a label via hyperlink?
Posted: Sun May 10, 2015 12:19 am
by FamuFamu
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?
Re: Passing control to a label via hyperlink?
Posted: Sun May 10, 2015 12:52 am
by PyTom
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)
Re: Passing control to a label via hyperlink?
Posted: Sun May 10, 2015 2:16 am
by FamuFamu
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.
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)
This way the links would look like big red words.
Thanks again!
Re: Passing control to a label via hyperlink?
Posted: Thu Aug 25, 2016 10:50 pm
by octacon100
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:
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)
That code also shows how to have the text change color when you hover over it. Hope that helps someone.