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?

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.
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...