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

  • #20, by afrlmeFriday, 20. February 2015, 16:46 6 years ago
    remove *all from the brackets.

    write / create...
    local file = io.open(localAppDir .. "Savegames/autosave1.txt", "w+")
    file:write( os.date("%F, %X") )
    file:close()
    1
    2
    3
    4


    read...
    local file = io.open(localAppDir .. "Savegames/autosave1.txt", "r")
    Values["autosave1"].ValueString = file:read()
    file:close()
    1
    2
    3
    4

    ...untested, but should work correctly.

    Imperator

    6841 Posts


  • #21, by ke4Friday, 20. February 2015, 17:22 6 years ago
    Thanks! Works in Visionaire, i just needed to change .ValueString to .String only ( without the path ) But in the build version with the vispath: it's not working.

    Key Killer

    810 Posts

  • #22, by afrlmeFriday, 20. February 2015, 17:38 6 years ago
    hmm yeah in current build it might just be .String. In next build you can use either.

    Ah yeah sorry. I didn't mean to use vispath. That's needed for playing sound files via Lua script. I meant to write...
    localAppDir .. "Savegames/autosave1.txt"
    1


    My bad! grin

    Imperator

    6841 Posts

  • #23, by ke4Friday, 20. February 2015, 17:50 6 years ago
    Well, it's not still working grin

    local file = io.open( localAppDir .. "Savegames/autosave1.txt", "r")
    1
    2


    Maybe i made the syntax wrong? Where this folder is supposed to be?

    Key Killer

    810 Posts

  • #24, by afrlmeFriday, 20. February 2015, 18:05 6 years ago
    Same place your log, save game & config.ini files get saved to since 4.x.

    c:/users/username/appdata/local/game name, company name or .ved name/...

    You may need to create a save game folder if it doesn't yet contain one. The folder will be automatically created when you save a game.

    Imperator

    6841 Posts

  • #25, by ke4Friday, 20. February 2015, 18:15 6 years ago
    Oh yeah and now it's working, the folder was missing. Thanks for help :-)

    So the whole code is:

    Write

    local file = io.open( localAppDir .. "Savegames/autosave1.txt", "w+")
    file:write(os.date("%c"))
    file:close()
    1
    2
    3
    4


    Read

    local file = io.open( localAppDir .. "Savegames/autosave1.txt", "r")
    Values["autosave1"].String = file:read()
    file:close()
    1
    2
    3
    4

    Key Killer

    810 Posts

  • #26, by afrlmeFriday, 20. February 2015, 18:24 6 years ago
    Aye although I think %c might generate a bit too much information no? According to the date parser it generates: Thu Aug 23 14:55:02 2001. The %F, %X, I wrote, generates: yyyy-mm-dd, hh:mm:ss. Just a little smaller, but I suppose it doesn't matter all that much. wink

    Imperator

    6841 Posts

  • #27, by ke4Friday, 20. February 2015, 18:35 6 years ago
    I know but it was crashing with that and it seems like %F doesnt even exist?
    http://www.lua.org/pil/22.1.html

    Key Killer

    810 Posts

  • #28, by afrlmeFriday, 20. February 2015, 18:46 6 years ago
    ahh.. yeah sorry, it was a c++ date handler I posted.

    You could do...
    "%X, %d/%m/%y" -- would return: 18:46:22, 20/02/15
    1
    2

    Imperator

    6841 Posts

  • #29, by ke4Friday, 20. February 2015, 18:51 6 years ago
    Haha.. you are learning quite a lot languages, didnt you say that you are starting with C#?

    and looks better that way smile

    Key Killer

    810 Posts

  • #30, by andy-rinaldiFriday, 20. February 2015, 19:11 6 years ago
    Hi guys, thanks a lot for the posts but maybe is better if someone tell me as if I were a child. It's really difficult for me understand.

    Forum Fan

    160 Posts

Write post