I test this modul and it is very great !
by theravano » Mon Aug 07, 2017 4:47 pm
Sorry but, how do i call for the achievements on the Script?
I will try to contribute to answer to theravano
To implement the code and "call" the achievement in your currently game, you have to :
Put the achievement.rpy file before the label start and add a code lign.
Here is my code :
Code: Select all
# Déclarez les personnages utilisés dans le jeu.
define e = Character('Eileen', color="#c8ffc8")
##### Achievement
################################################ Before label start
transform achievement_transform:
on show:
xalign .98
yalign -.3
linear 0.4 xalign .98 yalign .02
on hide:
linear 0.4 xalign 1.9 yalign .02
screen scr_achievement_get(title, a_text, icon, trans=achievement_transform):
timer 2.4 action Hide("scr_achievement_get")
window:
at trans
background "#333333cc"
xalign .98
yalign .02
xysize (450, 100)
hbox:
vbox:
spacing 10
image icon
vbox:
xoffset 10
xsize 330
text title:
size 28
id title
text a_text:
size 22
id a_text
screen scr_achievement_update(title, a_text, icon, cur_prog, max_prog, trans=achievement_transform):
timer 2.4 action Hide("scr_achievement_update")
window:
at trans
background "#333333cc"
xalign .98
yalign .02
xysize (450, 100)
#
hbox:
vbox:
spacing 10
image icon
text "{0}/{1}".format(cur_prog, max_prog):
xcenter 0.5
ycenter 0.2
vbox:
xoffset 10
xsize 330
text title:
size 28
id title
text a_text:
size 22
id a_text
init python:
def get_achievement(ach_id, trans=achievement_transform):
ach = persistent.achievements_dict[ach_id]
achievement.grant(ach_id)
renpy.show_screen(_screen_name='scr_achievement_get', title=ach['title'],
a_text=ach['text'], icon=ach['icon'], trans=trans)
def update_achievement(ach_id, to_add=1, trans=achievement_transform):
persistent.achievements_dict[ach_id]["cur_prog"] += to_add
ach = persistent.achievements_dict[ach_id]
achievement.progress(ach_id, to_add)
if ach['cur_prog'] > ach['max_prog']:
persistent.achievements_dict[ach_id]["cur_prog"] = ach['max_prog']
ach = persistent.achievements_dict[ach_id]
renpy.show_screen(_screen_name='scr_achievement_update', title=ach['title'], a_text=ach['text'],
icon=ach['icon'], cur_prog=ach['cur_prog'], max_prog=ach['max_prog'], trans=trans)
# Define your achievements here
if not persistent.achievements_dict:
persistent.achievements_dict = {"name": {"type": 0, # One time achievent
"title": "Un coeur tendre", # Also neame for steam
"text": "Relation romantique avec Azur débloquée !", # description
"icon": "images/Logo Achievement/Coeur.png" # 96x96 image
},
"name2": {"type": 1, # Progress achievent
"title": "Le mystère du Chateau",
"text": "Qui es-ce qui est à l'origine de ça ??",
"icon": "images/Logo Achievement/Coeur.png",
"cur_prog": 0, # current progress
"max_prog": 33 # maximal progress
}
}
for i, a in persistent.achievements_dict.items():
if a['type'] == 0:
achievement.register(i, steam=a['title'])
if a['type'] == 1:
achievement.register(i, steam=a['title'], stat_max=a['max_prog'])
##########################################################################################################################
label start:
#The game starts here
"A test to find how put fade"
menu:
"Lâchez-la !":
jump oh_Yes
"Ne rien faire.":
jump oh_No
label oh_Yes:
e "Bla bla"
$ get_achievement("name", trans=achievement_transform) ######## in the script, there wasn't " ", i add it.
e "A problem ?"
label oh_No:
e "no way !!!!"
return
i hope it will help you and i hope that don't make mistakes in my explanation