accessing the bookmark.dat files via lua

  • #1, by sebastianFriday, 07. August 2015, 16:01 5 years ago
    Hey guys,

    I have a question regarding a selfwritten savesystem im currently "scripting" using the autosave-system.
    So i have 8 available saveslots in my interface(!) menu to save an autosave file from (bookmark01.dat - bookmark08.dat).
    Currently i also create (and read) a file called "savegames.ini" and write down the date and name of each savegame (name is the current scene).

    Regarding to this i have to load the savegames.ini file to set some values ingame to the correct strings so they can be displayed as an object text in my save/load menu.

    The savegames.ini looks like that after saved on slot 1 and 4 on different dates:
    # Naming the savegames
    savegame_1 = Room 1 06.08.15 23:05
    savegame_2 = empty
    savegame_3 = empty
    savegame_4 = Room 2 07.08.15 13:34
    savegame_5 = empty
    savegame_6 = empty
    savegame_7 = empty
    savegame_8 = empty
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    When opening the save/load menu a function loads these lines into variables so they are up to date.
    Works nice so far.

    The problem i have here now is a "what if" scenario:
    What if...
    A) bookmark01.dat doesn't exist but a line in the savegames.ini still names it. So i have to check if it really exists and if not rewriting the variable to "Empty Slot".
    B) bookmark01.dat does exist but the entry in the savegames.ini file is missing. So i have to rename the slot to some kind of "sorry, forgot the name" -kind entry.

    So how do i solve this?

    I could to a filechecking, etc before loading these variables BUT MAYBE it is possible to read the current room name outside of the bookmark files and also load the creation/update-date / time from that file directly to load them up into variables from visionaire. So i have no trouble building a whole system around said bookmark files and a check system if these files still exist or entries are missing...

    So is it possible to access these bookmark files via Lua to extract some desired information ?

    kind regards
    Sebastian

    Thread Captain

    2334 Posts


  • #2, by afrlmeSaturday, 08. August 2015, 02:40 5 years ago
    The bookmark.dat files are encrypted, same as the regular save files. Try opening one up in sublime, atom or notepad++ & you'll see.

    I recommend using a new ini or txt file per quicksave as it's not so easy to simply overwrite the required line. To do so you need to read the file & store the data (preferably into a table) & then iterate through each one with a for loop & querying if line contains part of a specified string. For each line you iterate through you should be writing the original line to the ini file or the new data if the string matches the query, up until the end of the table.

    I don't know if what I said makes sense to you or not?

    Imperator

    6804 Posts

  • #3, by sebastianSaturday, 08. August 2015, 13:15 5 years ago
    yeah makes sense.

    It would be great to have some more lua functions from visionaire to access the .dat files in the future. (as they can access the "normal" savegame files and read out the date and screenshot it should be not that hard)

    Thread Captain

    2334 Posts

  • #4, by afrlmeSaturday, 08. August 2015, 15:21 5 years ago
    It's not Lua that's decrypting the savegame files, it will be internal c++ engine source code for the player executable probably.

    Lua has limited encryption & decryption options. SHA-1, ROT13, XOR, etc.

    https://gist.github.com/obikag/7035680 - rot13 example
    https://gist.github.com/obikag/7590516 - xor example

    Imperator

    6804 Posts

  • #5, by sebastianSaturday, 08. August 2015, 19:09 5 years ago
    isnt there any chance to let VS read the files via an action part then and save some stuff (e.g. modification date, current character, current room) into values to do further stuff in lua and/or action parts in the future? I would love to see this implemented...

    Thread Captain

    2334 Posts

  • #6, by afrlmeSunday, 09. August 2015, 02:04 5 years ago
    I don't think that would ever be added. Especially not as an action part. It's not exactly hard for you to write those details yourself mind by querying the system time/date, the current character & current scene data structure fields.

    Imperator

    6804 Posts

  • #7, by sebastianSunday, 09. August 2015, 02:57 5 years ago
    yeah i know. My idea is a bit special but everytime i read about "visionaire doesnt require programming skills" for creating the basic things it makes me sad because the savemenu stuff is either lacking of features (autosave) or too strict in how it should look and work (normal saves).

    So just as an idea and kind of wish for a future VS version it would be cool to have more possibilities for "no programmers".

    Thread Captain

    2334 Posts

  • #8, by afrlmeSunday, 09. August 2015, 13:43 5 years ago
    I believe SimonS is working on making it more artist friendly. He's overhauling the GUI for a future update & removing wxwidgets (bane of most vs problems). The general idea is to make it more workflow friendly & to give the devs more freedom in implementing new ideas without the limitations of wxwidgets.

    Imperator

    6804 Posts

  • #9, by sebastianSunday, 09. August 2015, 18:52 5 years ago
    sounds promising.

    for now i have built a save/load system which checks if the savegame-files exist and if yes checking the name in the savegames.ini to do some crazy stuff. unwieldy and inconvenient but working (n___n)" ...

    Thanks so far for the support smile

    Thread Captain

    2334 Posts

  • #10, by LebosteinMonday, 10. August 2015, 15:57 5 years ago
    Why savegame files are encrypted?

    Key Killer

    598 Posts

  • #11, by sebastianMonday, 10. August 2015, 16:30 5 years ago
    i think its good to prevent manipulating the savegames external. cheaters gonna cheat wink

    Thread Captain

    2334 Posts

Write post