Login
Remember
IF Answers
Ask a Question

# Can't get game to refresh itself

0 votes
71 views
asked Jun 23 in Authoring by anonymous

Squiffy 2 or 3 or 4
I've uploaded the game to my website. At the [[END]] section I inform the player that the game has ended and he can close his browser. Ok, When I create another tab or a new window and proceed to play the game again. The whole game is laid out before me just as it was when I ended the game and closed my browser. I tried putting @clear in the [[END]] section as the last line, but all that does is clear all the previous sections and leases the game still open so that when I open another tab and try playing the game again I am brought back to the END section and the game won't start again until I click on Restart link. What can I do that will insure a fresh start each time the game is opened?

- squiffy

## 1 Answer

+1 vote
answered Jun 23 by Alex (486 points)

Squiffy always automatically saves the game as it goes along, so you can leave it and come back later.

To restart the game from the beginning, you need to click the Restart link at the top.

If you want to force a restart, you can do that via JavaScript. For example, in your final section:

    [[END]]:
    That's all folks. [[Start again]]

    [[Start again]]:
        $('#squiffy').squiffy('restart');

commented Jun 24 by anonymous
Sorry, That didn't work. Every thing was just as I had left it. Same as before. As I see it your code is supposed to give me a clicable link "Start Again" which then runs
"[[Start again]]:
$('#squiffy').squiffy('restart');"
I want the Code to just reset back to the beginning and then let the player close his browser because otherwise he might forget to click the link and be in the same position as before. See what I mean? The Restart link is always there anyway so this code would be superfluous. But anyway I don't know why the code didn't work I am not fluent in jQuery.
commented Jun 24 by Alex (486 points)
If you currently had a game session stored in your browser, that won't be updated with the new "Start again" link. That will only be displayed when anybody reaches the ending from now on, so you'll need to Restart manually and play to the end if you want to see it yourself.
commented Jun 24 by anonymous
OK how about changing index.html or story.js? I am not a strong programmer, but I do know a little on how to modify code. I notice you are using jQuery and if I have to I will go to codeschool and learn jQuery. It's a powerful lanquage and simpler than JS but more confusing I think, at first.
Thanks,
Paul
commented Jun 24 by anonymous
edited Jun 24
Is there a way to programatically "flush" the browser's cashe, other than CTRL + F5?
Nevermind i googled and saw there is no reliable way :(
commented Jun 24 by Alex (486 points)
You can clear the localStorage, which is where Squiffy stores the game state, using localStorage.clear() - but there won't be a way of getting this to run from your game if it's in an end state with no links remaining. Just get your players to click the obvious Restart link at the top.
commented Jun 24 by anonymous
OK sigh.. I guess that's the end of it.

## Related questions

- Is there a way to turn Squiffy passage links into a regular link for accessibility purposes?
- Squiffy: How to force two variables to equal based off another variable?
- Squiffy: How to fix if else error?
- How to compare two variables in Squiffy?
- How to deal with large numbers in Squiffy?

...