questions regarding save menu + loading a saved game

  • #10, by sebastianThursday, 16. July 2015, 18:05 9 years ago
    what about letting the player enter a short string (keyinput) when saving? is this possible?

    Thread Captain

    2346 Posts


  • #11, by afrlmeThursday, 16. July 2015, 18:12 9 years ago
    Yes but you would need to program this with the key actions (long method) or with the Lua key event handler (faster method). You then store each key press into a variable or value, which you can then include in the function you will create for writing the data to an external file.

    Imperator

    7281 Posts

  • #12, by sebastianThursday, 16. July 2015, 18:19 9 years ago
    key event handler seems to be more effective here. Even if i dont know how to proceed axactly with it.
    Do i have to write for every key a value or can i append each pressed key to an existing string (value) to make the word appear?
    (im not experienced enough in lua to know whats possible and what not)

    thanks so far smile

    regards
    Sebastian

    Thread Captain

    2346 Posts

  • #13, by afrlmeThursday, 16. July 2015, 19:24 9 years ago
    It's possible using the Lua key event handler to have it print the character (well most of the characters, as some of the special keys will only return a keycode or something instead, but for your basic a-z, 1-9 it will work just fine).

    http://wiki.visionaire-tracker.net/wiki/RegisterEventHandler

    Imperator

    7281 Posts

  • #14, by sebastianThursday, 16. July 2015, 20:37 9 years ago
    i'll give it a try.
    I think i will do a basic classic save-menu without screenshot. Just ~8 Slots (Lines) where you can click and then enter a string and press save.
    Clicking on a Slot which already has a save state will make it possible to edit the line or/and clicking the save button overwrite the existing savegame.

    EDIT: I saw it is possible to unregister the eventhandler. So i make these handlrs only available in the save menu to save resources

    Thread Captain

    2346 Posts

  • #15, by afrlmeThursday, 16. July 2015, 20:44 9 years ago
    The unregisterEventHandler() function only applies to "mainLoop" events, this is because the "mainLoop" is the only event that you can have multiple instances of. All the rest of the event types can only be created once per project.

    Imperator

    7281 Posts

  • #16, by sebastianThursday, 16. July 2015, 21:19 9 years ago
    good to know.
    I will try this out at the weekend and give feedback as soon as i have something to present (or fail roll ).

    Thread Captain

    2346 Posts

  • #17, by sebastianFriday, 17. July 2015, 20:46 9 years ago
    Ok, looking over it makes it a bit to complex to implement "naming the saves". Instead i only want to autoname it to the Scene the player is currently in.
    Is it possible to set a value string to the current Scene name defined in the properties tab of a scene?

    Thread Captain

    2346 Posts

  • #18, by afrlmeFriday, 17. July 2015, 21:25 9 years ago
    Yep smile

    You could do something like...
    Values["value_name"].String = game.CurrentScene:getName()
    


    I think it's .String or it could be .ValueString. I forget which is the correct call method.

    Example: add current scene table name, current computer date & time to value "autosave_1"...
    Values["autosave_1"].String = game:CurrentScene:getName() .. ", " .. os.date()
    


    Then again it might be more beneficial to return the scene of the current character as current scene will always be the one displayed, which isn't much good if you are using a menu scene for the saving & loading of games. Current scene would only be applicable if you created the custom save / load interface as part of a menu.

    Imperator

    7281 Posts

  • #19, by sebastianSaturday, 18. July 2015, 16:20 9 years ago
    i had to use this:
    Values["saveslot_1"].String = game:getLink(VGameCurrentScene):getName() .. " " .. os.date("%d.%m.%y %H:%M Uhr")
    


    sadly it saves the internal name of the scene and not the language-defined :/

    Thread Captain

    2346 Posts

  • #20, by afrlmeSaturday, 18. July 2015, 17:42 9 years ago
    You can get the language table names too. http://wiki.visionaire-tracker.net/wiki/Scripting#getTextStr

    os.date() should return something like: dd/mm/yyyy - hh:mm:ss.ms. or the other way around - I forget. Although it is possible to input custom values as you have done. smile

    Imperator

    7281 Posts