Save names + time elapsed playing? [solved]

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.
Message
Author
User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Save names + time elapsed playing? [solved]

#1 Post by Soraminako » Mon Oct 10, 2011 12:59 am

Hello everybody!

I just switched from the conventional load/save page to the vertical/scrolling type, and for now everything is working properly. *knocks on wood* XD

I wanted to add the feature of having the save files display a name (possibly the name of the chapter/whatever the player is in at the moment they saved), and also maybe the length of time played. But I have no idea how to go about doing that. :X

Anyone knows how to do it? :oops: I couldn't find anything in the docs, or in my forum search. It must be that I'm not calling it the right name, because I'd think other people must have tried to do this before...?

Mine has this, but I don't know how to get the name to show up.

Code: Select all

    config.time_format = "%d %b, %H:%M"
   
    config.file_entry_format = "%(time)s\n%(save_name)s"
How should I set up save names and where? And what about the length of time played?

Thank you in advance for any help you can give me! :oops:
Last edited by Soraminako on Thu Oct 20, 2011 8:59 pm, edited 6 times in total.
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Names for the save files + time elapsed playing?

#2 Post by DragoonHP » Mon Oct 10, 2011 4:27 am

Don't know how to show up time, but for showing up name...

Code: Select all

$ store.save_name = "Name"

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: Names for the save files + time elapsed playing?

#3 Post by Soraminako » Mon Oct 10, 2011 4:52 pm

Thank you!! :D That works great!!

As for the time, I've been messing with it today and think I've finally gotten it working.

I tried using the wiki code ( http://www.renpy.org/wiki/renpy/doc/ref ... me_runtime ) but it didn't work, at least not combined with the save_name part, so instead I did a frankenstein of that code + other bits of code I've found in threads of the forum and somehow it worked! (XD)

I used this:

Code: Select all

    $ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
    
    $ mychapter = "Chapter 01: blah blah blah"
    $ myplace = "Candy land from hell"
    $ save_name = "  %(chapt)s \n  You have been playing for %(minmin)d minutes and %(secsec)d seconds and you are currently at %(blah)s!" % {"chapt": mychapter, "minmin": minutes, "secsec": seconds, "blah":myplace}
It baffles me why we can't use "minutes" and "seconds" from the start, but when I tried to it crashed, so... "minmin" and "secsec" it is, stupid as it may sound. XD Maybe it was just that I was doing it wrong or something.

I have to repeat that whole chunk of code in each new chapter name/place, but oh well, at least now it works right as I wanted. :D
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Names for the save files + time elapsed playing? [solved

#4 Post by DragoonHP » Mon Oct 10, 2011 5:05 pm

:-p

I feel silly... of course I saw this one in Moonwalk...

And it's just a thought, but maybe you can make it a function and have arguments return those places and chapters name...
Just a thought...

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: Names for the save files + time elapsed playing? [solved

#5 Post by Soraminako » Mon Oct 10, 2011 6:08 pm

A function & arguments? ^^; That would be great, but I have no idea how I could do it.

Ah, I've encountered a problem with my time measuring thing. :( It only gives the time accurately if you save immediately after the area where the time is measured with that code. Otherwise, if you save some time later but not yet at the next chapter change/next time that code is listed, it will give the same time as it was in the last time that was in the code, so whatever the time was at the previous chapter title change area. :(

Do you have any ideas for how to make the time to be measured accurately all along the game? ^^;
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Names for the save files + time elapsed playing? [solved

#6 Post by DragoonHP » Tue Oct 11, 2011 7:06 am

Soraminako wrote:A function & arguments? ^^; That would be great, but I have no idea how I could do it.
Just noticed that it will only complicate the code more.. since you will need to enter the place name again and again ...
Soraminako wrote:Ah, I've encountered a problem with my time measuring thing. :( It only gives the time accurately if you save immediately after the area where the time is measured with that code. Otherwise, if you save some time later but not yet at the next chapter change/next time that code is listed, it will give the same time as it was in the last time that was in the code, so whatever the time was at the previous chapter title change area. :(
That thing is to be expected because the code asks for the runtime of that instant... see the code, it's get_game_runtime...

The one thing which you can do is make sure that the game stores the time as soon as the player goes to the save screen...

Your best bet will be fiddling with screen language, (and if you manage to find out, please do tell me... screen language is a new concept to me because the only game I made was in RenPy v11.1 and I'm pretty sure it didn't have screen language)...

Or you can put in like this:

Code: Select all

## only for customised menu:
label menu:
    $ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
    $ save_name = "  %(chapt)s \n  You have been playing for %(minmin)d minutes and %(secsec)d seconds and you are currently at %(blah)s!" % {"chapt": mychapter, "minmin": minutes, "secsec": seconds, "blah":myplace}
Like every code, I just complied it in my head, so I'm not sure if it will work perfectly or not... but I think it should... if I were to take a wild guess, I will say the chances are 80%...

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: Save names + time elapsed playing? [partially solved]

#7 Post by Soraminako » Wed Oct 12, 2011 4:53 pm

That bit of code you wrote, do you mean it goes in the save screen menu?

Edit: I tried it in the menu just now and it crashes the game. (It says it won't work because the variables are not defined in the menu, and we can't define them there since the chapter names etc. are defined as the game progresses.) Did you mean to put it elsewhere?

As for screen language, I'm terrible at it, so we'll see how that goes. XD lol
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Save names + time elapsed playing? [partially solved]

#8 Post by DragoonHP » Wed Oct 12, 2011 8:43 pm

Ah... I meant to put it there... ah I guess...

And give me a little time, I need to think about this one...

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Save names + time elapsed playing? [main problem not sol

#9 Post by DragoonHP » Sun Oct 16, 2011 5:21 am

YAY!!!!!!!!!!!!!! I did it...
I should have gone with this from the start... I am silly... it would have saved me time...

Anyway... there's the template code...

Code: Select all

# You can place the script of your game in this file.

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8")


# The game starts here.
label start:
    
    $_game_menu_screen = "getTime"

    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"
    
    e "This is annoying..."
    
    e "Why do I have to do this for test purpose..."
    
    e "Argh.,.."
    
    e "Stop it already..."

    return
    
label getTime:
    
    $ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
   
    $ mychapter = "Chapter 01: blah blah blah"
    $ myplace = "Candy land from hell"
    $ save_name = "  %(chapt)s \n  You have been playing for %(minmin)d minutes and %(secsec)d seconds and you are currently at %(blah)s!" % {"chapt": mychapter, "minmin": minutes, "secsec": seconds, "blah":myplace}
    
    jump save_screen
    
    return
    
EDIT: Make sure you put the variables myplace and mychapter in the start of a new chapter or a new place... they do not need to be put in the getTime label...

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: Save names + time elapsed playing? [main problem not sol

#10 Post by Soraminako » Sun Oct 16, 2011 12:52 pm

Did the code work for you in a test? I tried it just now and it did nothing at all. :(

I tried it first with the way it was written and saw that the chapter & place variables weren't being used if they stayed in get time, so I moved them to the label with Eileen speaking, and also saw your edit about it.
But that didn't change anything since the save name can't be used so it's not showing the chapter etc. when you save.

Then I tried to move the longer line with the save name etc. into the label also to see if it would work, but then it crashes the game because it doesn't have the time measuring thing in the same label.
So I moved that line too, and as a result now have the entire content of the get time label in the start label, which is probably not how it should be, but well... it also doesn't work. :(

It's really a pity, I'd gotten so hopeful when I saw the code.

Any idea of what might be going wrong? ^^;
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Save names + time elapsed playing? [main problem not sol

#11 Post by DragoonHP » Sun Oct 16, 2011 1:00 pm

Hmm... it works for me...

Can you post the traceback...?
Attachments
Untitled1.png

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Save names + time elapsed playing? [main problem not sol

#12 Post by DragoonHP » Sun Oct 16, 2011 1:05 pm

Hmm... it works for me...

Can you post the traceback...?

PS: I have checked it with Ren'Py v6.12.1 and Ren'Py v6.13.6... and it seems to work just fine...

Try to clear the persistent... and then try again...
And if you can, try to clear the persistent manually... for some reasons, Ren'Py couldn't clear the persistent... maybe it was because I was using two different versions to test it...
Anyway, at least make sure that the persistent is deleted...
Attachments
Untitled1.png

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: Save names + time elapsed playing? [main problem not sol

#13 Post by Soraminako » Sun Oct 16, 2011 1:38 pm

It works!! :D :D Thank you so much!!

I found what the problem was:
In the code in your post, there was a typo. "$_game_menu_screen = "getTime"" was missing a space between "$" and "_". Once I noticed that and added the space your code works perfectly! :D

Thank you so much!! :D *so happy with it working*
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Save names + time elapsed playing? [all solved! :D]

#14 Post by DragoonHP » Sun Oct 16, 2011 1:47 pm

Code: Select all

In the code in your post, there was a typo. "$_game_menu_screen = "getTime"" was missing a space between "$" and "_". 
That's not a typo... >.< and anyway I don't think spaces matter there...

But I'm glad that the code works...

User avatar
Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: Save names + time elapsed playing? [all solved! :D]

#15 Post by Soraminako » Sun Oct 16, 2011 2:01 pm

Really? :? But the lack of space there was causing "$" and "_game_menu_screen" to be a same word lumped together, and as a result it wasn't recognizing "_game_menu_screen" and the line starting with "$" was all black instead of having the colors they normally have in the editor.
Once the space was added it all started working. Until then the code wasn't doing anything, the saves were looking exactly as they do in the default ren'py.

In any case, it's awesome, and thank you very much for the help with that. :D
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]