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

  • #10, by afrlmeMonday, 16. February 2015, 22:10 9 years ago
    hmm... you mean via the createScreenshot() function? No I don't think so, it takes the screenshot at the default game resolution regardless of what resolution the game has been scaled down to. I'm not 100% sure but I think you can use Lua script to link an objects sprite to another image & from that you might be able to scale the image using the new VObjectScale data structure table to another scale percentage. Again, not sure without testing.

    Imperator

    7278 Posts


  • #11, by andy-rinaldiMonday, 16. February 2015, 23:05 9 years ago
    I could:
    exec autosave
    create screenshot
    scaling the image
    Objects["thumbautosave"].Scale = 0.21
    


    Now I should set the image position in my scene.
    I try with
    obj = getObject("thumbautosave")
    moveObj(obj, 54, 171)
    

    but the movObj don't works...

    Forum Fan

    160 Posts

  • #12, by afrlmeMonday, 16. February 2015, 23:21 9 years ago
    moveObj is a workflow function I wrote. It requires the script I wrote to be included inside of a definition script, however I don't recommend using it as it's based on offset. In the upcoming release is a new action part which allows you to move an object to specified coordinates instead of using offset. I would recommend adding the image as an animation or line up the top left pixel to where you want it to be placed instead as it should scale down into the correct position automatically then. I don't think it shifts position when you scale up/down. The top-left pixel should stay in the same place.

    Imperator

    7278 Posts

  • #13, by andy-rinaldiFriday, 20. February 2015, 00:00 9 years ago
    It's possible insert the autosave timestamp informations in the config.ini file?

    Forum Fan

    160 Posts

  • #14, by afrlmeFriday, 20. February 2015, 00:12 9 years ago
    Sure or another file entirely. .cfg, .txt, .log, .x, etc - maybe even a file without a format, although not sure about that.

    Imperator

    7278 Posts

  • #15, by andy-rinaldiFriday, 20. February 2015, 06:30 9 years ago
    I mean to save a variable with time info in config.ini.
    I found how display a datetime variable in my savegame menu but when I quit the game, I lost the time stored in my variable...
    Thanks.

    Forum Fan

    160 Posts

  • #16, by afrlmeFriday, 20. February 2015, 12:51 9 years ago
    Because variables & values are stored in save game files, which means that, that information will have been reset to its initial state on game launch, until you restore the data by loading a save file.

    Writing & reading data to / from an external files does not rely on save game data, which is why you can have the game restore option settings & retrieve other data on game launch such as achievements, bonus unlocks, date / time, player profile names & so on.

    Please see: here & here, for more information regarding the config.ini & reading / writing of external files.

    Imperator

    7278 Posts

  • #17, by ke4Friday, 20. February 2015, 16:14 9 years ago
    I was testing it a bit, works fine for writing.

    local file = io.open("autosave1.txt", "w+")
    file:write(os.date("%c"))
    file:close()
    


    but i can't get the data into the value, if i print out file:read("*all"), it prints the file, but when i put it into the value and print the value, it's empty.

    local file = io.open("autosave1.txt", "r")
    getObject("Values[autosave1]"):setValue(VValueString, file:read("*all"))
    file:close()
    

    Key Killer

    810 Posts

  • #18, by afrlmeFriday, 20. February 2015, 16:18 9 years ago
    You need to read the individual lines. Check out whatever method I used for reading from the config.ini script.

    * edit: technically you could even use a single file & have it search for a prefix. if it finds said prefix then you just have it return the data of that line minus the prefix by using the string.sub/gsub functions.

    Imperator

    7278 Posts

  • #19, by ke4Friday, 20. February 2015, 16:31 9 years ago
    It's actually hard to read for me from that script you linked, could you please show me how to simply read the first line?

    Key Killer

    810 Posts

  • #20, by afrlmeFriday, 20. February 2015, 16:46 9 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()
    


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

    ...untested, but should work correctly.

    Imperator

    7278 Posts