Hmm total time played?

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.
Post Reply
Message
Author
Melkoshi
Regular
Posts: 156
Joined: Tue Jun 02, 2009 8:56 pm
Projects: Jewels of Sytinane
Location: U.s.a.
Contact:

Hmm total time played?

#1 Post by Melkoshi » Wed Nov 10, 2010 8:21 pm

I remember seeing this before somewhere, but I can not find it for the life of me!

I'm doing my save/load screen atm. and I'm wondering if theres a function or variable set up to collect the "total played" variable.

Also, is there a way to 'collect' the current say into the save aswell? I've seen this in VNs before and I like that idea.

I know I can do the title, with filesavename. But i'm looking for it to save aswell the current say dialog. :s

thanks!

edit: I found this, but i'm unsure how to add this into a way that the save files will grab it. >>

Code: Select all

    $ hours = int(renpy.get_game_runtime()) // 3600
    $ minutes = int(renpy.get_game_runtime()) // 60
    "You finished the game in %(hours)d and %(minutes)d minutes."
--- My DeviantArt.
Game in Progress for demo-teaser:
story(script) = 45%
sprites = 100%
programming(interface) = 35%
CGs = 0%
Backgrounds = 5%
Music/sound = 0%

Melkoshi
Regular
Posts: 156
Joined: Tue Jun 02, 2009 8:56 pm
Projects: Jewels of Sytinane
Location: U.s.a.
Contact:

Re: Hmm total time played?

#2 Post by Melkoshi » Sun Nov 14, 2010 6:48 pm

bumpage. o.o anyone got any advice for adding the total time stamp to a save?

I haven't messed with the file functions yet, so if it's mega easy. forgive me. XD
--- My DeviantArt.
Game in Progress for demo-teaser:
story(script) = 45%
sprites = 100%
programming(interface) = 35%
CGs = 0%
Backgrounds = 5%
Music/sound = 0%

Melkoshi
Regular
Posts: 156
Joined: Tue Jun 02, 2009 8:56 pm
Projects: Jewels of Sytinane
Location: U.s.a.
Contact:

Re: Hmm total time played?

#3 Post by Melkoshi » Tue Nov 16, 2010 12:05 am

Okay. I tried adding in a custom File action(Seems possible to do?). However it gives me tracebacks anytime i try to use savedata.

First I copyed the FileTime function from the screens common to see how it was done. I altered it to this.

Code: Select all

def FileTotalTime(name, format="%b %d, %H:%M", empty="", page=None):
        """
         :doc: file_action_function 
         
         Returns the time the file was saved, formatted according
         to the supplied `format`. If the file is not found, `empty` is
         returned.

         The return value is a string.
         """
        
        save_data = renpy.scan_saved_game(__filename(name, page))

        if save_data is None:
            return empty

        extra_info, displayable, save_time, total_time = save_data
        
        return renpy.get_game_runtime(total_time)      
Clearly this wont work. It gives me a traceback about how a global variable is undefined, or a traceback about a bad amount.

I also tried just using it like the code pasted, but inside the menu. I figured it wouldn't work that simple, and it doesn't.

anyone got any clue on how to add a "total time played" to the save files please? it can't be impossible...can it? :c

(I dont mean to keep posting as i hate double+ posting. but wow I can't figure this one out.)
--- My DeviantArt.
Game in Progress for demo-teaser:
story(script) = 45%
sprites = 100%
programming(interface) = 35%
CGs = 0%
Backgrounds = 5%
Music/sound = 0%

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: Hmm total time played?

#4 Post by DaFool » Tue Nov 16, 2010 12:55 am

I would like to know the answer to this myself, hence bumping. (Sorry to get your hopes up, I'll research into this when I get home).

All I can think off (pulling from the references) is something like

Code: Select all

$ rawplaytime = renpy.get_game_runtime()

python:
    renpy.take_screenshot()
    renpy.save("chapter2", "Start of chapter 2.", rawplaytime)
Then later when retrieving

Code: Select all

python:
    import time
    saveGames = renpy.list_saved_games()
    saveTime = time.asctime(time.localtime(saveGames[0][3]))
    savePlayTime = time.asctime(time.localtime(saveGames[0][2])) #I'm guessing at this point which tuple location the extra info of playtime is stored at
   
label next:
  
    "time of first save slot = %(saveTime)s"
    "playtime of first save slot = %(savePlayTime)s"
The code can be totally false... but that's the gist of my general direction.
Last edited by DaFool on Tue Nov 16, 2010 1:23 am, edited 2 times in total.

Incendium
Regular
Posts: 25
Joined: Wed Dec 09, 2009 12:57 am
Contact:

Re: Hmm total time played?

#5 Post by Incendium » Tue Nov 16, 2010 1:10 am

You can save the time in the save_name variable for the save when using FileSave, which will store the value of save_name in the save file in a place which is easily accessible. When you want to pull the time from a particular save, you can use the FileSaveName function. You will also need to assign a function to config.auto_save_extra_info which returns the time played if you want auto saves to work properly as well.

Keep in mind this data is stored as a string so be careful with trying to store structured data like a dict or list there.

Melkoshi
Regular
Posts: 156
Joined: Tue Jun 02, 2009 8:56 pm
Projects: Jewels of Sytinane
Location: U.s.a.
Contact:

Re: Hmm total time played?

#6 Post by Melkoshi » Tue Nov 16, 2010 3:50 pm

Well thats a start at least. I'll play around with that one.

I wanna keep the save name however...(infact i wanna add to it if possible. such as last line spoken)

I hear your warning about lists or dict in that. How safe would it be to allow multiple items inside such a thing? :S If the only choice is to completely override it, it'll have to do..

edit:

GOT IT!!!

and it looks like i CAN have more information aswell.

this is what i did so far.

Code: Select all

    $ hours = int(renpy.get_game_runtime()) // 3600
    $ save_name = "Confrontation - %d" % hours 


edit50million:
I ended up fudging it around. this is my label that i call before entering save which shows how i got the veriables in the savename to work.

Code: Select all

label test:
    $ minutes = int(renpy.get_game_runtime()) 
    $ said = minutes
    $ blah = "place"
    $ save_name = "I said %(blah)s and %(blah2)s!" % {"blah": said, "blah2": blah}
--- My DeviantArt.
Game in Progress for demo-teaser:
story(script) = 45%
sprites = 100%
programming(interface) = 35%
CGs = 0%
Backgrounds = 5%
Music/sound = 0%

Post Reply

Who is online

Users browsing this forum: Google [Bot]