Howdy, Stranger!

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

Only show the load option if a save exists [Harlowe 1.2.2, Twine 2]

Hello,

I am currently using Harlowe on Twine 2.
I have a story with a cover page that works as a start screen.
The page has the following options:

"New Game"
"Load Game"
"Achievements"
"About"

I am having trouble with the "Load Game" option: I would like it to only show up if a saved game exists.
If a saved game doesn't exist, I would like it to appear as greyed out / unclickable text.

Right now, my code for loading a game looks like this:
[Load Game]<restore|</li>{(click: ?restore)[Done!(loadgame: "A")]}

And for saving it is:
[Save]<save|
{(click: ?save)[Done!(savegame: "A")]

And I would think this issue could be easily resolved with an if:/else: statement, ie: if a savegame exists, show the code above; else show plain text.

I can't, however figure out what to put in the if: clause.


Note: I haven't figured out the Achievements yet, but I'll most likely open a new thread for that soon.

Comments

  • The second example included in the (saved-games: ) macro's documentation shows how to check if a particular save game exist.
  • Hi Meylanna,

    I used the example greyelf mentioned with color like this:
    (if: (saved-games:) contains "Slot A")[
        (link: "Load game")[
            (load-game: "Slot A")
        ]
    ](else: )[
        (color: "#696969")[
            Load Game
        ]
    ]
    

    I have also been toying with achievements infrastructure so I might have a few insights when you open your thread for those!
  • edited September 2016
    greyelf wrote: »
    The second example included in the (saved-games: ) macro's documentation shows how to check if a particular save game exist.

    Hi! This is what I've been using, but I am still seeing the error.
    Since both @greyelf and @Ceadda confirmed that this is how it is supposed to work, I tested it out in different browsers and realised this is working perfectly except for internet explorer.
    I thought it was my fault before because I used IE as an alternative browser to check when there is no file.

    I have attached a screenshot of what I see.

    Diapositiva1.PNG
  • If you are loading your project locally, then that is likely the problem. IE (and probably Edge) disable Web Storage, among other things, for files which are opened via file://. While I could be wrong, I'd bet that Harlowe's saves rely on Web Storage—there's nothing unusual about that, SugarCube is the same.

    Blink-based browsers (Chromium, Chrome, Opera) also disable various things, or simply make them crash, for files which are opened via file://.
  • If you are loading your project locally, then that is likely the problem. IE (and probably Edge) disable Web Storage, among other things, for files which are opened via file://. While I could be wrong, I'd bet that Harlowe's saves rely on Web Storage—there's nothing unusual about that, SugarCube is the same.

    Blink-based browsers (Chromium, Chrome, Opera) also disable various things, or simply make them crash, for files which are opened via file://.

    Shoot. You are right! I am an idiot!
    Thank you. :smile:
  • Not an idiot, just one of the inevitable victim in the fight between security and comfort. Comfortable things were disabled for a reason, and it's usually security reasons. Better safe than sorry, right?
  • ... Comfortable things were disabled for a reason, and it's usually security reasons. Better safe than sorry, right?

    This is an interesting subject, and I agree with you on principle, though I don't necessarily agree 100% with the way security is enforced right now.
    I think that it should be much more transparent to users what is being done to protect them, and that with so many services now collecting user data for profiling (and for profit), runing a html page locally seems like a much smaller issue. :smile:
Sign In or Register to comment.