[SOLVED] Help with showing save FileTime in a custom Save Load screen

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
User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

[SOLVED] Help with showing save FileTime in a custom Save Load screen

#1 Post by RicharDann »

I'm currently finishing a Custom Save Screen another member of my team designed, he passed me the completed screen code (wich he created from scratch) so I could add functionality to the buttons so they
perform the saving/loading process. That part is mostly done, now we want each save slot to have some specific info, like the player's name and lv,wich should be no problem, but the time and date is giving me some trouble figuring out. You see, scanning through the default scripts I noticed the save screen uses what seems to be a function called FileTime, wich should return the time a file was saved, or so I thought. When I use it in my custom screen, it shows the time but keeps updating it constantly for some reason, so when the time changes in my PC's clock, it reflects immediately in the screen, and of course I don't want that. I tried saving the returned string into a variable but that led to unexpected problems when I load the save file (ex. the hour changes inconsistently).

Am I doing something wrong? Is there a better way to accomplish this?

Code: Select all


#Here are the functions my friend wrote to manage the save process

init python:

    def CreateSaveFile(file_slot):
        name = "DataFile%i" % file_slot
        message = "File %i Saved."% file_slot
        renpy.save(name)
        renpy.notify(message)

    def LoadSaveFile(file_slot):
        name = "DataFile%i" % file_slot
        message = "File %i Loaded."% file_slot
        renpy.load(name)
 
#Here's our custom screen, not complete just the relevant parts that could be causing the problem

screen save_load_buttons():

    frame:
             id "DateDisplay"
             xysize(300,30)
             ypos 660
             yanchor 1.0
             background "#292929"
             text FileTime(1, format=_("{#file_time}%A, %d, %H:%M"), empty=_(" "))
             
    imagebutton:
             auto "gui/button/svit_%s.png"
             xpos .50
             ypos 0
             xanchor .5
             yanchor 0
             action [
                     If(renpy.get_screen("save"), true=Confirm(prompt="Save File 1?", yes=Function(CreateSaveFile, 1), no=None)),
                     If(renpy.get_screen("load"), true=Confirm(prompt="Load File 1?", yes=Function(LoadSaveFile, 1), no=None), false=None),
                    ]
This screen is "used" inside the save screen and the load screen, instead of the file_slots screen.

I should add that I'm passing 1 as an argument because of the way this screen was designed since the game will only have 3 save files (Don't ask me why, they want it that way so who am I to argue?), and this is the button for Save 1. Since my friend wrote his own variant of the save system, I'd like to stick to it as much as I can, it saves and loads perfectly so I don't know if the issue is because of this, could it be?

EDIT:
I figured it out. Thank you Danny for your effort, persistent does seem to work, I'll have to adapt and write a little more code to ensure compatibility and minimize possible errors, but this problem is solved for now.
Last edited by RicharDann on Thu Sep 07, 2017 10:07 am, edited 1 time in total.
The most important step is always the next one.

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: Help with showing save FileTime in a custom Save Load screen

#2 Post by DannyGMaster »

You can show the date on screen using a persistent variable and a function using the time module, included in Python. It works for now in my testing, but the way persistent works is a little confusing right now, I'll have to study it deeper but that would be a different issue. If I get the code to work properly I'll share it here.
The silent voice within one's heart whispers the most profound wisdom.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]