Skip to content

Instantly share code, notes, and snippets.

@debnath
Last active June 5, 2024 15:30
Show Gist options
  • Save debnath/6ed41a0f48dbfaa0f892f4b4f0e88432 to your computer and use it in GitHub Desktop.
Save debnath/6ed41a0f48dbfaa0f892f4b4f0e88432 to your computer and use it in GitHub Desktop.
How to save and load the state of the paperclips game (www.decisionproblem.com/paperclips/index2.html)
The paperclips game over at www.decisionproblem.com/paperclips/index2.html is great, but if you want to play the game indefinitely you can lose all progress if you clear browser cache or change laptop.
I wanted a way to create a save file and load it later, so I did. Use the below script to generate the output to load the current game state.
var saveGame=localStorage.getItem("saveGame"),savePrestige=localStorage.getItem("savePrestige"),saveProjectsActive=localStorage.getItem("saveProjectsActive"),saveProjectsFlags=localStorage.getItem("saveProjectsFlags"),saveProjectsUses=localStorage.getItem("saveProjectsUses"),saveStratsActive=localStorage.getItem("saveStratsActive"),restoreString="/************* COPY ALL TEXT BELOW THIS LINE AND SAVE IN A TEXTFILE SOMEWHERE. RUN IT IN ANY CHROME OR FIREFOX CONSOLE TO LOAD IT. *************/\nlocalStorage.setItem('saveGame', '"+saveGame+"') \nlocalStorage.setItem('savePrestige', '"+savePrestige+"') \nlocalStorage.setItem('saveProjectsActive', '"+saveProjectsActive+"') \nlocalStorage.setItem('saveProjectsFlags', '"+saveProjectsFlags+"') \nlocalStorage.setItem('saveProjectsUses', '"+saveProjectsUses+"') \nlocalStorage.setItem('saveStratsActive', '"+saveStratsActive+"') \n";console.log(restoreString);
1) If you don't know how to run it, first, copy the above script into your clipboard (highlight the entire line above and press command c).
2) Then, in Chrome, go to the paperclip game webpage -> right-click on your mouse -> click 'inspect' -> click 'console' -> rightclick and press 'paste' -> press enter.
3) You'll see a bunch of grey text appear under "COPY ALL TEXT BELOW THIS LINE AND SAVE IN A TEXTFILE SOMEWHERE". Save that text to a textfile or email somewhere. This will be your savegame file.
4) Whenever you want to load that savefile, just go back into the console (mentioned in step2) and paste the contents that you saved in step 3.
5) You will need to repeat steps 1-4 every time you want to save the game.
@pww22
Copy link

pww22 commented Nov 22, 2019

Nice work Debnath, keep changing the world buddy

@BadZooka
Copy link

BadZooka commented Aug 24, 2022

Is this still working? I used the command line to get my save state, saved it in a *.txt-file, but now whenever I enter the copied contents into the console while on the site my Chrome console just returns 'undefined'.
EDIT: I just noticed that, after pasting the contents of my file, I cannot access the game at all when reloading the page. The error message:
Uncaught TypeError: loadPrestige is null loadPrestige https://www.decisionproblem.com/paperclips/main.js?v3:6497 <anonymous> https://www.decisionproblem.com/paperclips/main.js?v3:4181

@git42leech
Copy link

@BadZooka, you’ll have to edit the script as suggested. Works perfectly fine once it’s edited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment