I have this code:
Code: Select all
label start:
scene bg lake
"There is a {a}canoe{/a} over there."
return
Thanks!
Code: Select all
label start:
scene bg lake
"There is a {a}canoe{/a} over there."
return
Code: Select all
label start:
scene bg lake
"There is a {a=show:canoe_text}canoe{/a} over there."
return
screen canoe_text():
text "A canoe is a lightweight narrow vessel."
timer 2.0 action Hide("canoe_text")
Code: Select all
define e = Character("Eileen")
init python:
lexicon = {
('Visual Novel', 'VN') : """
A visual novel (bijuaru noberu) is an interactive game genre,
which originated in Japan in the early 1990s, featuring mostly
static graphics, most often using anime-style art or occasionally
live-action stills.
As the name might suggest, they resemble mixed-media novels.""",
('Ren\'Py', 'Renpy') : """
The Ren'Py Visual Novel Engine is a free software engine which
facilitates the creation of visual novels, a form of
computer-mediated storytelling. Ren'Py is a portmanteau of ren'ai,
the Japanese word for 'romantic love' and Python,
the programming language that Ren'Py runs on. """
}
def hyperlink_lexicon( str_to_test ):
for keys in lexicon:
for phrase in keys:
# preceded by a space
str_to_test = str_to_test.replace(
" {0}".format(phrase),
" {{a=lexicon:{phrase}}}{phrase}{{/a}}".format(
phrase = phrase ) )
# followed by a space
str_to_test = str_to_test.replace(
"{0} ".format(phrase),
"{{a=lexicon:{phrase}}}{phrase}{{/a}} ".format(
phrase = phrase ) )
return str_to_test
config.say_menu_text_filter = hyperlink_lexicon
def hyperlink_styler(*args):
return style.hyperlink_text
def hyperlink_hovered(*args):
if not args[0]:
# tried renpy.hide_screen ... no joy
return
elif args[0][:8] == "lexicon:":
renpy.show_screen( "lexicon_popup",
args[0][8:],
renpy.get_mouse_pos() )
renpy.restart_interaction()
def hyperlink_clicked(*args):
# We could add a function for clicked here
return None
style.default.hyperlink_functions = ( hyperlink_styler,
hyperlink_clicked,
hyperlink_hovered )
screen lexicon_popup(phrase=None, pos=(100,100)):
if phrase:
python:
# get description
d = [ lexicon[k] for k in lexicon if phrase in k ]
description = d[0] if len(d) else "No description found."
description = " ".join( [ k for k in description.split()
if k not in [" ", "\t"] ] )
# move the ypos up by a bit
pos = ( pos[0], pos[1] - 25 )
# reformat phrase
p = [ k for k in lexicon if phrase in k ]
primary_phrase = p[0][0] if len(p) else phrase
if primary_phrase != phrase:
phrase = "{0} ({1})".format(phrase, primary_phrase)
frame:
anchor (0.5, 1.0)
pos pos
xsize 340
background Solid("#A9B")
vbox:
text "[phrase]" size 18
text "[description]" size 14
# Hacky workaround as hyperlink_hovered does not seem to nicely hide this
# Just hide after (4 words per second) guesstimate delay
timer len(description.split()) / 4.0 action Hide("lexicon_popup")
label start:
e "Start"
e "Oh look, this VN is made with Ren'Py"
e "Test phrases that should not make link... AVNX aRenpyx"
e "End"
Users browsing this forum: No registered users