Percent complete feature...? [SOLVED]
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.
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.
- Boniae
- Regular
- Posts: 187
- Joined: Fri Apr 10, 2009 4:10 pm
- Completed: I want 2 be single and Forget-Me-Not
- Projects: Cry Girlhood, Dakota Wanderers, Sagebrush
- Organization: Rosewater Games
- Tumblr: boniae
- Location: Cleveland, OH
- Contact:
Percent complete feature...? [SOLVED]
I've seen this kind of feature in a couple of Japanese games before. In the save menu there will be a box or a bar with the percent of how complete you are with the game. My game has become pretty lengthy, so I think putting a percent at the bottom of the save menu or something could help people get an idea of how far it is until they're done. (With one playthrough though, not like the entire game/endings.) Is there any way I could make a feature like this...? Thanks!
Last edited by Boniae on Sat Jul 27, 2013 3:50 pm, edited 1 time in total.
- jesusalva
- Regular
- Posts: 88
- Joined: Mon Jul 22, 2013 5:05 pm
- Organization: Software in Public Interest, Inc.
- IRC Nick: jesusalva
- Github: pazkero
- itch: tmw2
- Location: Brazil
- Discord: Jesusalva#4449
- Contact:
Re: Percent complete feature...?
Hmm... That should be an easy way...
you can see if the player saw scene x.
when he see, you can set a persistent variable.
eg.:
that will add 4 completation points
you just need retrieve the data. and if you clear persistent data it is also cleared.
This piece of code you put in init. it will see if you declared it.
it should work.
you can see if the player saw scene x.
when he see, you can set a persistent variable.
eg.:
Code: Select all
label N55:
"You" "So... you're Harper?"
$ persistent.complete += 4
"Harper" "Yes, I am!"
"You" "Glad to meet you!"
jump N55b
you just need retrieve the data. and if you clear persistent data it is also cleared.
Code: Select all
if persistent.complete is None:
persistent.complete = 0
it should work.
Jesusaves/Jesusalva
Re: Percent complete feature...?
Actually, such simple method will cause problem This is because it allows the player can easily get 100% completion by simply watching the same scene again and again (since it add points every time).
A better way is this:
Let's say you have 5 scenes that are important and so count toward % completion. Then at each scene you add something like this
all the way to
Then, whenever you need to come up with a percentage number, you just need to count how many of these persistent variable have been set, so something like this:
Then use that number in anyway you want. You could display them, or use it to draw a progress bar.
A better way is this:
Let's say you have 5 scenes that are important and so count toward % completion. Then at each scene you add something like this
Code: Select all
$persistent.key_scene_1=True #at the end of the 1st scene
Code: Select all
$persistent.key_scene_5=True #at the end of the 5th scene
Code: Select all
label calculate_pc:
$key_scene_count=0 #number of important scene seen, start counting from 0
$key_scene_total=5 #in this example we have 5 important scenes
if persistent.key_scene_1:
$key_scene_count+=1
if persistent.key_scene_2:
$key_scene_count+=1
if persistent.key_scene_3:
$key_scene_count+=1
if persistent.key_scene_4:
$key_scene_count+=1
if persistent.key_scene_5:
$key_scene_count+=1
$pc=(int)((float)(key_scene_count)*100/key_scene_total) #these (int) and (float) are just numeric conversion to give you integer
- jesusalva
- Regular
- Posts: 88
- Joined: Mon Jul 22, 2013 5:05 pm
- Organization: Software in Public Interest, Inc.
- IRC Nick: jesusalva
- Github: pazkero
- itch: tmw2
- Location: Brazil
- Discord: Jesusalva#4449
- Contact:
Re: Percent complete feature...?
Hmm... Yes, I forgot that.
you method is really better
you method is really better
Jesusaves/Jesusalva
- Boniae
- Regular
- Posts: 187
- Joined: Fri Apr 10, 2009 4:10 pm
- Completed: I want 2 be single and Forget-Me-Not
- Projects: Cry Girlhood, Dakota Wanderers, Sagebrush
- Organization: Rosewater Games
- Tumblr: boniae
- Location: Cleveland, OH
- Contact:
Re: Percent complete feature...?
Oh wow, thank you both so much for the help!!!
Unfortunately I'm kinda hopeless with programming, so how exactly would I show that variable in the save menu...? (Like "x percent completed".) And should I use the label calculate_pc only once? (like at the end of the script)
Unfortunately I'm kinda hopeless with programming, so how exactly would I show that variable in the save menu...? (Like "x percent completed".) And should I use the label calculate_pc only once? (like at the end of the script)
- jesusalva
- Regular
- Posts: 88
- Joined: Mon Jul 22, 2013 5:05 pm
- Organization: Software in Public Interest, Inc.
- IRC Nick: jesusalva
- Github: pazkero
- itch: tmw2
- Location: Brazil
- Discord: Jesusalva#4449
- Contact:
Re: Percent complete feature...?
Hehe, That I can answer.
I'm sure that you will learn how customize, but it is the code:
the problem? you will need declare it after each increment.
WAIT! I've said how it be included while saving. it will be a label in the savegame.
You want show in preferences screen?
around line 350 in screens.rpy you will see the following:
you can just add a new label:
That might work.
The save game menu is next to line 264, just modify it,I'm going to sleep now.
I'm sure that you will learn how customize, but it is the code:
Code: Select all
$ save_name = " " + persistent.complete + "\% Completed"
WAIT! I've said how it be included while saving. it will be a label in the savegame.
You want show in preferences screen?
around line 350 in screens.rpy you will see the following:
Code: Select all
screen preferences:
Code: Select all
vbox:
frame:
style_group "pref"
has vbox
label _("Display mode:")
textbutton _("Window") action Preference("display", "window")
textbutton _("Fullscreen") action Preference("display", "fullscreen")
frame:
style_group "pref"
has vbox
label _("Transitions:")
textbutton _("All") action Preference("transitions", "all")
textbutton _("None") action Preference("transitions", "none")
frame:
style_group "pref"
has vbox
label _("Velocidade de Texto:")
bar value Preference("text speed")
frame:
style_group "pref"
has vbox
textbutton _("configurar Joystick...") action ShowMenu("joystick_preferences")
## Here us start adding.
frame:
style_group "pref"
has vbox
label _("Progesso:" + persistent.complete + "\%")
## Here us end adding.
The save game menu is next to line 264, just modify it,
Jesusaves/Jesusalva
- BlueScorpion
- Newbie
- Posts: 14
- Joined: Thu Jul 25, 2013 4:01 am
- Contact:
Re: Percent complete feature...?
Ok, so i threw this together. They don't both work at the same time though, so just choose one.
Persistent data method...
method where data is unique to each save
Both appear to work, but i did not test them extensively. There may be bugs.
Persistent data method...
Code: Select all
#++++++++++++++++++++++++++++++++++++
#+++this method saves data that pertains to all playthroughs of the game
#+++
init python:
#+++
def GenerateNodes(n):
d = {}
for i in range(0, n):
d[i] = False
return d
#+++
def pass_node(n):
if n in persistent.progress_node:
persistent.progress_node[n] = True
#+++
def PercentComplete():
count = 0
for i in persistent.progress_node:
if persistent.progress_node[i]:
count += 1
#+++
return int( float(count*100) / len(persistent.progress_node) )
#+++
if persistent.progress_node == None:
persistent.progress_node = GenerateNodes(10)#< -- set this number to how ever many you need
#+++
#++++++++++++++++++++++++++++++++++++
#+++this screen shows your current progress
# go to your screens.rpy and find the save and load screens...
# then...
#
#screen save:
#
# # This ensures that any other menu screen is replaced.
# tag menu
#
# use navigation
# use file_picker
# use progress#<<--add this line here
#
#screen load:
#
# # This ensures that any other menu screen is replaced.
# tag menu
#
# use navigation
# use file_picker
# use progress#<<--and this line here
#
screen progress:
if not renpy.context()._main_menu:
$ current_progress = PercentComplete()
hbox:
xalign 1.0 yalign 0
bar value current_progress range 100 xmaximum 150 thumb None thumb_shadow None
text (str(current_progress)+'%')
#+++it's up to you to place them throughout your game script
label start:
"Some stuff happens!"
$ pass_node (0)
"Some more stuff happens!"
$ pass_node (1)
"The story unfolds."
"How exciting!"
$ pass_node (2)
menu:
"There might be a choice":
"Where different things happen."
$ pass_node (3)
"Depending on what you do":
"You see different things."
$ pass_node (4)
"You must play more than once":
"To reach 100%%."
$ pass_node (5)
"Regardless, the plot continues to rampage."
"Even blood sacrifice cannot appease it."
$ pass_node (6)
"All..."
$ pass_node (7)
"The way..."
$ pass_node (8)
"Up to..."
$ pass_node (9)
"The End"
return
Code: Select all
#++++++++++++++++++++++++++++++++++++
#+++this method will only pertain to the current playthrough and will reset to 0% every time a new game is started
#+++
init python:
progress_node = {}
#+++
def GenerateNodes(n):
global progress_node
#+++
progress_node = {}
for i in range(0, n):
progress_node[i] = False
#+++
def pass_node(n):
global progress_node
#+++
if n in progress_node:
progress_node[n] = True
#+++
def PercentComplete():
count = 0
for i in progress_node:
if progress_node[i]:
count += 1
#+++
return int( float(count*100) / len(progress_node) )
#+++
#++++++++++++++++++++++++++++++++++++
#+++this screen shows your current progress
# go to your screens.rpy and find the save and load screens...
# then...
#
#screen save:
#
# # This ensures that any other menu screen is replaced.
# tag menu
#
# use navigation
# use file_picker
# use progress#<<--add this line here
#
#screen load:
#
# # This ensures that any other menu screen is replaced.
# tag menu
#
# use navigation
# use file_picker
# use progress#<<--and this line here
#
screen progress:
if not renpy.context()._main_menu:
$ current_progress = PercentComplete()
hbox:
xalign 1.0 yalign 0
#has hbox
bar value current_progress range 100 xmaximum 150 thumb None thumb_shadow None
text (str(current_progress)+'%')
#++++++++++++++++++++++++++++++++++++
#+++it's up to you to place nodes throughout your game script
label start:
$ GenerateNodes(10)#< -- set this number to how ever many you need
"Some stuff happens!"
$ pass_node (0)
"Some more stuff happens!"
$ pass_node (1)
"The story unfolds."
"How exciting!"
$ pass_node (2)
menu:
"There might be a choice":
"Where different things happen."
"Depending on what you do":
"You see different things."
"You must play more than once":
"To reach 100%%."
$ pass_node (3)
"In this case you probably don't want to have nodes placed in such a way..."
"...that the player will be unable to hit them all in a single play-through."
$ pass_node (4)
"If the story must branch, you should place nodes along each path."
$ pass_node (5)
menu:
"Path 1":
jump path1
"Path 2":
jump path2
label path1:
$ pass_node (6)
"Picking a pathway..."
$ pass_node (7)
"And following it..."
$ pass_node (8)
"To its logical conclusion."
$ pass_node (9)
jump end
label path2:
$ pass_node (6)
"And then..."
$ pass_node (7)
"Having your nodes distributed along the other pathway..."
$ pass_node (8)
"Until reaching the end."
$ pass_node (9)
jump end
label end:
"The End"
return
- Boniae
- Regular
- Posts: 187
- Joined: Fri Apr 10, 2009 4:10 pm
- Completed: I want 2 be single and Forget-Me-Not
- Projects: Cry Girlhood, Dakota Wanderers, Sagebrush
- Organization: Rosewater Games
- Tumblr: boniae
- Location: Cleveland, OH
- Contact:
Re: Percent complete feature...? [SOLVED]
Ahhh, I tested your code out BlueScorpion and it works! Woohoo! No bugs so far so I think it's good to go.
Thanks everyone for all the help!!!
Thanks everyone for all the help!!!
Who is online
Users browsing this forum: Google [Bot]