Display datetime of a autosave file in the game save load menu

  • #40, by afrlmeFriday, 20. February 2015, 22:58 6 years ago
    Oh by the way... what I said earlier about narration text, not positioning correctly. I forgot that I was running a text handler which repositions all text to the bottom of the screen.

    Quick note: the save game folder needs to exist for it to be able to write the file to it, as the file must also exist to read from it. You could add an additional query to check if the file exists or not before trying to read it.

    By the way, why are you writing to a bookmark.dat file? The bookmarkxx.dat filenames should not be written to as that is what the quicksave/autosave system creates the files as. Use .txt or .x or .cfg or leave the file extension blank even. Call it something like timestampX.txt where x should be the index value of the quicksave file.

    I see you have employed the looping method for background narration text that I used for the key input demo template I provided a while back. @ ke4: it's a good method as it constantly updates the text on each loop. You can also cancel out the action in an at end of scene action part.

    Imperator

    6842 Posts


  • #41, by andy-rinaldiFriday, 20. February 2015, 23:18 6 years ago
    Sorry guys, I had not realized.. confuse I have put a timestamp.txt file but the display_text is not working yet. Yesterday I tried it in the same position and it was working...

    @AFRLme: Yeah, you looping method works fine!

    Forum Fan

    160 Posts

  • #42, by afrlmeSaturday, 21. February 2015, 01:33 6 years ago
    display narration text is working fine for me. I also employed the same loop as the text update for updating the time every 1 second. In theory I suppose you could use this action for updating the playtime in an external file too by reading the current time adding it into a value & then writing the new value plus 1. It's technically possible to split seconds into hh:mm format.

    here's a little function I just wrote for converting seconds to hh:mm:ss format...
    local h, m, s

    function secs2hms(v)
    h = math.floor(v / 3600)
    m = math.floor(v % 3600 / 60)
    s = math.floor(v % 3600 % 60)
    -- + --
    print( h .. ":" .. m .. ":" .. s )
    end
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    ...currently it just prints the value to the log file but you could simply replace the print line with a line that updates the value of a string. So technically you can use the same value for both the integer & string value. Inside of a loop you just have it increase said value by 1 every second & then have it update the string value straight after it, which will update the display narration text value on its next loop & voila you have a simple playtime counter. wink

    Also here's another function for converting time. This one converts seconds into dd:hh:mm:ss format.
    local d, h, m, s

    function secondsToTime(v)
    d = math.floor(v / 86400)
    h = math.floor(v % 86400 / 3600)
    m = math.floor(v % 3600 / 60)
    s = math.floor(v % 3600 % 60)
    -- + --
    print( d .. ":" .. h .. ":" .. m .. ":" .. s )
    end
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11

    ...mental note: there are 86400 seconds in a day (apparently) & there are 3600 seconds in an hour, as there are 60 seconds in a minute. Thank bugrit there are lots of conversion calculators & examples on the internet as my math skills are terrible! grin

    Imperator

    6842 Posts

  • #43, by andy-rinaldiSaturday, 21. February 2015, 11:51 6 years ago
    Thank you Lee, I have several display narration text in my game and they work fine but this is not working. In the past there was a scene that did not display background images and buttons. Then a day it worked fine without touching...I don'know.

    Forum Fan

    160 Posts

  • #44, by afrlmeSaturday, 21. February 2015, 12:39 6 years ago
    Are there any errors listed in the log file?

    P.S: The time conversion functions I provided above are not quite complete as they are missing some if queries to add the additional "0" in case value returned is less than "10".

    Here's the updated version of both scripts...
    local d, h, m, s -- empty variables which will be used for storing the split time values

    -- function for converting seconds to time format (hh:mm:ss)
    function secs2hms(v)
    h = math.floor(v / 3600)
    m = math.floor(v % 3600 / 60)
    s = math.floor(v % 3600 % 60)
    -- + --
    if h < 10 then h = tostring("0" .. h) end
    if m < 10 then m = tostring("0" .. m) end
    if s < 10 then s = tostring("0" .. s) end
    -- + --
    print( h .. ":" .. m .. ":" .. s )
    end

    -- function for converting seconds to time format (dd:hh:mm:ss)
    function secondsToTime(v)
    d = math.floor(v / 86400)
    h = math.floor(v % 86400 / 3600)
    m = math.floor(v % 3600 / 60)
    s = math.floor(v % 3600 % 60)
    -- + --
    if d < 10 then d = tostring("0" .. d) end
    if h < 10 then h = tostring("0" .. h) end
    if m < 10 then m = tostring("0" .. m) end
    if s < 10 then s = tostring("0" .. s) end
    -- + --
    print( d .. ":" .. h .. ":" .. m .. ":" .. s )
    end
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30

    Imperator

    6842 Posts

  • #45, by andy-rinaldiSaturday, 21. February 2015, 18:40 6 years ago
    ahaha, you're right. I always forget to check the message log. I have solved... was my fault.
    Many thanks.

    Forum Fan

    160 Posts

  • #46, by afrlmeMonday, 23. February 2015, 00:04 6 years ago
    Here's a Playtime counter tutorial & template I sorted out the day.

    Imperator

    6842 Posts

Write post