Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Custom Save File Names

I want to be able to call upon save files that the player can name and eventually load up again.
I have got the custom names working but I can't print links to load the save file with the custom name.
The
(load-game:)
macro requires you to know what the save file was in order to have a link to load it.
(if: (save-game: (prompt: "Name your Save" + " "(current-time:) + " " (current-date:))))
[Game Saved. (current-time:)](else:)[Save Failed]
Any suggestions?

Comments

  • You need to state the name and full version number of the Story Format you are using, as answers can be different for each one. Based on the syntax of your examples I will assume you are using Harlowe.
    Catman wrote: »
    ...call upon save files...
    Harlowe saves are not files they are records stored within your web-browser's local storage cache.

    The (saved-games:) macro when combined with the (datanames: ) macro can be used to obtain an Array containing the names of the known saves.
    (set: $name to "some" + "thing")
    (save-game: $name)
    
    (set: $array to (datanames: (saved-games:)))
    (print: $array)
    


    How you loop the contents of that array and create links based on the names stored within it depends on which version of Harlowe you are using.
  • I am using Harlowe 1.2.3
    How would you create the links based on the names?
  • Currently Harlowe 1.x does not have an equivalent of Harlowe 2.x's (for: ) macro, so you will need to use one of the possible methods to emulate the functionality.

    The following solution uses the Display Macro Recursion with a Named Hook method to emulate looping.

    1 Add code like following to the passage you want the list of load game links to appear in:
    []<list|{
    (set: $list to (datanames: (saved-games:)))
    (set: $index to 0)
    (if: $index < $list's length)[(display: "Display Load Link")]
    }
    

    2. Create a Display Load Link passage and add the following code to it:
    {
    (set: $index to it + 1)
    (if: $index > 1)[
    	(append: ?list)[<br>]
    ]
    (append: ?list)[(print: "(link: $list's ($index))[(load-game: $list's ($index))]")]
    (if: $index < $list's length)[(display: "Display Load Link")]
    }
    

    note: You can change the names of the Named Hook, the Variables and the Displayed Passage to whatever makes sense in your story, as long as you update the code in points 1 & 2 to include the new names.
Sign In or Register to comment.