22lblevins

Coolmath - Tower of Colors Script

May 7th, 2022 (edited)
1,023
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var key = "mjs-tower-of-colors-island-edition-v1.0.0";
  2.  
  3. function getLS() {
  4.     if (localStorage.gameState) {
  5.         return JSON.parse(localStorage.getItem(key));
  6.     } else {
  7.         return false;
  8.     }
  9. }
  10.  
  11. function setLS(input) {
  12.     try {
  13.         localStorage.setItem(key, JSON.stringify(input));
  14.         refreshGame();
  15.     } catch {
  16.         console.warn("Unable to set localStorage!");
  17.     }
  18. }
  19.  
  20. function clearLS() {
  21.     try {
  22.         localStorage.removeItem(key);
  23.         refreshGame();
  24.         return true;
  25.     } catch {
  26.         return false;
  27.     }
  28. }
  29.  
  30. function refreshGame() {
  31.     cmg_remove_padg();
  32. }
  33.  
  34. //
  35.  
  36. function setCoins(val) {
  37.     var t = getLS();
  38.     t.coin = val;
  39.     setLS(t);
  40. }
  41.  
  42. function setHighScore(val) {
  43.     var t = getLS();
  44.     t.highscore = val;
  45.     setLS(t);
  46. }
  47.  
  48. function setWildshot(val) {
  49.     var t = getLS();
  50.     t.wildshot = val;
  51.     setLS(t);
  52. }
  53.  
  54. function setLaserbeam(val) {
  55.     var t = getLS();
  56.     t.laserbeam = val;
  57.     setLS(t);
  58. }
  59.  
  60. function setAll(val) {
  61.     setCoins(val);
  62.     setHighScore(val);
  63.     setWildshot(val);
  64.     setLaserbeam(val);
  65. }
  66.  
  67.  
Add Comment
Please, Sign In to add comment