Saving System

*Note: This article is about Season 1. Some information may be outdated.*

*Note: Cloud Variable is shortened to CV for this page*

The saving system functions by saving your data in 4 different CVs. There are 2 buttons in the upper middle of the screen dubbed "Save" and "Load" and save is to the right of load. Hitting the save button saves your current progress in CVs. The cloud code format is very easy to modify, but that would be cheating. When load is clicked, your CVs turn into towers. Take into account that you cannot load progress from earlier or future updates because the CVs are saved in the specific version of the game. This is unfortunately an issue with Scratch, not the game, and is such unfixable without some coding knowledge for now. As of 7/12/2022, if you want to load your game into future updates you must modify the code of "Load" to regain your progress.

## Save Feature

The save feature doesn't save all the progress you have made, but instead it saves all the progress you made when you clicked the save button. There is a limit of how many towers you can save, which is 999. If you save above the tower limit you risk damaging the code and the load code will be 1 digit off, so don't save if you have over 1000 of 1 tower. Thankfully there is not a limit to the amount of cookies or lumps that can be saved. This is due to the fact that they are separated into 2 different CVs, whereas for the Buildings CV it's set to many numerical and word values. In the cookie and lumps saving CV, the amount of cookies and lumps are directly set to be the CV. However this cannot be done for the buildings because they can be set to any value. In order for a CV to contain more than 1 value, those numerical values must be separated by non numerical values.

However numerical values are weird. For example the letter "a" has a value greater than 1, but it's also less than 1. You also cannot combine non numerical values using the \_+\_ operator because scratch doesn't recognize the values. You may be wondering why separate CVs for each of the buildings weren't used. This is because there is a maximum of 10 CVs per project. Furthermore, using less CVs means more flexibility for later updates to saving.

Anyway, the "Buildings CV" would be set to the building name + the building amount variable. To get around the \_+\_ operator problem, the "join" operator was used. The difference between the "Join" and \_+\_ operator is that the join operator puts the 2 values next to each other instead of adding them. So 1 join 5 would be 15 while 1 + 5 is 6. The "join" operator also works with letters, so non numerical values can be added with numerical values. So far the code is {Set Buildings CV to [Join cursor amount with (Variable) cursor amount]}.

The block letter \_ of \_ was used to determine the value of the amount of buildings. Therefore, letter 5 of "cur 10 gran 2" is 1 (we're counting spaces), but we have to do letter 5 and 6 in order to get 10 and letter 5, 6 and 7 to get 100. In the example above letter 8 of the example is r, however However if you add an extra place values it will interfere with the "letter \_ of \_" code. The letters would all be shifted over by 1 starting from the increase, so letter 8 of "cur 100 gran 2" will not be g instead of r. The solution is using the function value( ) the value of a single space is less than 0.

## Load Feature

When the load button is clicked and the save feature is not empty then the code will start. A variable "k" will be increased by 1 every 0.1 seconds until the amount is equal to letter(something), (something), (something) of CV. Since the value (\_) is not replaced by letters combining (\_) with 1 equals (\_1). The way that I got around this is by using "if letter() not equal (\_)" then changing the variable "what letter" by 1. "If what letter + 1" Not equal (\_) then change what letter by 2. This effectively allows me to control what letter the code chooses, despite there being hundreds of possible combinations all with different results.