EDIT:
I add pronunciation of words (thanks to enaielei): viewtopic.php?f=8&t=65672&p=556534#p556522
screen.rpy
Code: Select all
init python:
config.hyperlink_handlers["play"] = renpy.play # Sound is linked to speech by hyperlink handlers.
screen glossary():
text "Glossary" size 40 xalign 0.5 ypos 20
hbox spacing 200:
viewport:
xpos 50 ypos 100 xsize 300 ysize 500
child_size (None, 4000)
scrollbars "vertical"
spacing 5
draggable True
mousewheel True
arrowkeys True
add "#000c"
vbox spacing 20:
#for word in sorted(persistent.palabra): # works only persistent words with nothing special
#for word in sorted(persistent.palabra, reverse=True) : # changes the order of presentation
for word in sorted(persistent.palabra, key=str.lower) : # order the list :D
textbutton word:
action SetVariable("display_desc", word)
vbox ypos 100 xsize 650 ysize 500 box_wrap True:
text glossary_dict.get(display_desc, "")
init -1 python:
display_desc = ""
######################################################
# Choose only one option for the glossary word to read: ##
######################################################
# Option 1: Pronunciation with robotic effect ##
#-----------------------------------------------------------------------##
def play(tag, argument, contents): ##
renpy.play(argument) ##
return contents ##
##
config.custom_text_tags["play"] = play ##
#----------------------------------------------------------------------##
#####################################################
# Option 2: Pronunciation normal ##
#---------------------------------------------------------------------##
config.hyperlink_handlers["play"] = renpy.play ##
#---------------------------------------------------------------------##
####################################################
#add words to the dictionary
glossary_dict = \
{
##################################################################
# If you chose the first option:
#'Cook': '{play=audio/cook.mp3}DEFINITION COOK OR WHATEVER{/play}',
#If you chose the SECOND option:
#'Cook': '{a=play:cook.mp3}DEFINITION COOK OR WHATEVER{/a}',
##################################################################
'Cut': '{play=audio/cut.mp3}DEFINITION CUT OR WHATEVER{/play}',
'a':'{play=audio/a.mp3}DEFINITION A OR WHATEVER{/play}',
'say':'{play=audio/say.mp3}DEFINITION SAY OR WHATEVER{/play}',
}
script.rpy
Code: Select all
define persistent.palabra= set()
label start:
show screen glossary
"¿?"
"¿Nothing?"
hide screen glossary
"Don't work?"
"Maybe..."
jump checking_words
label checking_words:
"Let's see..."
$ persistent.palabra.add('Cook')
show screen glossary
"Adding 'Cook'."
#$ persistent.palabra.remove('Cook') ##: To remove the word "Cook" from the glossary
"Yay!!!! ♥"
hide screen glossary
"If I add 'Cut'..."
$ persistent.palabra.add('Cut')
"..."
show screen glossary
"Oh! Adding 'Cut'."
"¡¡¡¡¡AAAAHHHHHH!!!!! It's working!!!!! :D"
hide screen glossary
"If I add 'a'..."
$ persistent.palabra.add('a')
"..."
show screen glossary
"It's working.... ♥"
"The end?"
return