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.
-
Milkymalk
- Miko-Class Veteran
- Posts: 752
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
-
Contact:
#1
Post
by Milkymalk » Mon Jan 13, 2014 10:47 pm
I tried fiddling around with styles a bit and tried to change the style in which hyperlinks appear. The code below works (mostly copied from the hyperlink example), but the hyperlink does not gain focus nor does clicking it do anything anymore. If I comment out the marked line (i.e., don't apply the new style), everything works fine but I changed nothing (of course).
My guess is that I am completely off-track and misunderstood something so badly that I just can't figure out the right way...
Code: Select all
init python:
style.lexikon = Style(style.hyperlink_text)
style.lexikon.bold = True
style.lexikon.color = "#aaaaff"
style.lexikon.underline = False
lexikon = Character(None, window_yfill=True, window_xmargin=20,
window_ymargin=20, window_background=Solid((0, 0, 0, 192)))
def hyperlink_styler(target):
return style.lexikon
config.hyperlink_styler = hyperlink_styler # <----------- crucial line
label define_quine:
lexikon "Quine:\n\nA program that prints itself to its output."
return
# The game starts here.
label start:
"A game that instructs on how to make a game? Isn't that a sort of {a=define_quine}Quine{/a}?"
# ...
return
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
-
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:
#2
Post
by PyTom » Sat Jan 18, 2014 12:45 am
You probably want to use the hyperlink_functions style property, rather than config.hyperlink_styler.
Code: Select all
init python:
def hyperlink_styler(target):
return style.lexicon
def hyperlink_callback(target):
# handle click.
return
style.default.hyperlink_functions = (hyperlink_styler, hyperlink_callback, None)
You very likely also want to set your lexicon style to something that changes on mouseover.
Code: Select all
style.lexikon = Style(style.hyperlink_text)
style.lexikon.bold = True
style.lexikon.color = "#aaaaff"
style.lexikon.underline = False
style.lexikon.hover_underline = True
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
-
Milkymalk
- Miko-Class Veteran
- Posts: 752
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
-
Contact:
#3
Post
by Milkymalk » Wed Jan 22, 2014 12:15 pm
To be honest I was fishing in the dark, copying snippets of code that were given for similar questions elsewhere and trying to get them to work like I want.
I found another solution now. But nevertheless thank you, this helped me understand how hyperlink_functions actually works!
This is what I found to work:
Code: Select all
init python:
style.lexikon = Style(style.say_dialogue) # base style to work with
style.lexikon.bold = True
style.lexikon.color = "#aaaaff"
style.lexikon.hover_color = "#ffffff"
style.lexikon.underline = False
style.hyperlink_text = style.lexikon
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Users browsing this forum: Bing [Bot], Google [Bot], span4ev