<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=Saving_Data</id>
	<title>Saving Data - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=Saving_Data"/>
	<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Saving_Data&amp;action=history"/>
	<updated>2026-06-27T20:14:17Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Saving_Data&amp;diff=1674&amp;oldid=prev</id>
		<title>Patarakin: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Saving_Data&amp;diff=1674&amp;oldid=prev"/>
		<updated>2022-07-21T08:33:13Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 11:33, 21 июля 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key digida:diff:1.41:old-1673:rev-1674 --&gt;
&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Saving_Data&amp;diff=1673&amp;oldid=prev</id>
		<title>scratch&gt;TemplatesFTW: Automated edit: fixed 1 style guideline</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Saving_Data&amp;diff=1673&amp;oldid=prev"/>
		<updated>2021-12-29T11:54:36Z</updated>

		<summary type="html">&lt;p&gt;Automated edit: fixed 1 style guideline&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In a [[Scratch]] [[project]], the act of &amp;#039;&amp;#039;&amp;#039;saving data&amp;#039;&amp;#039;&amp;#039; is to record a [[variable]], [[list]], or some other value so it can be read or used at a later time.&lt;br /&gt;
&lt;br /&gt;
==How it Works==&lt;br /&gt;
When saving data, the variable, list, or value is converted into a code containing all of the currently saved data. This process is called encoding.&lt;br /&gt;
&lt;br /&gt;
When the user would like to load the saved data, the saved code is converted back into the original values that were used to generate it. The project can then read and use these values like normal. This process is called decoding.&lt;br /&gt;
&lt;br /&gt;
==Common Uses==&lt;br /&gt;
Common uses of data-saving systems in Scratch projects include:&lt;br /&gt;
* Storing player status in games&lt;br /&gt;
* Saving users&amp;#039; work in paint projects&lt;br /&gt;
&lt;br /&gt;
This is not an exhaustive list; there are many more uses beyond those listed.&lt;br /&gt;
&lt;br /&gt;
==Making a Save Data System==&lt;br /&gt;
Once the data is encoded, it is the user&amp;#039;s responsibility to save the code for later. If the user wants to load their saved data, they must enter their code manually.&lt;br /&gt;
&lt;br /&gt;
===Encoding (Saving Data)===&lt;br /&gt;
This is what the project will use to generate save codes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
define save (data)&lt;br /&gt;
set [code v] to (join (join (code) [;]) (join (data) [;])&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
Now this custom block can be called whenever saving is needed.&lt;br /&gt;
Here&amp;#039;s an example of this block in action:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when flag clicked&lt;br /&gt;
set [code v] to ()&lt;br /&gt;
when [s v] key pressed&lt;br /&gt;
save (level):: custom&lt;br /&gt;
save (coins):: custom&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
In this example, pressing S will save the &amp;quot;level&amp;quot; and &amp;quot;coins&amp;quot; variables into a single code.&lt;br /&gt;
&lt;br /&gt;
===Decoding (Loading Data)===&lt;br /&gt;
Now the data is saved, what&amp;#039;s left is to encode it and switch it back to the original so the project can use it. This can be done by reading each value in the (saved) code (by reading until a semi-column is read, then the system switches to reading the next value). Here is how:&lt;br /&gt;
&lt;br /&gt;
Once the data is saved, the project must decode it so it can be read again. This is done by reading each portion of the code (separated by semicolons) and saving them into a list. The data can then be read by the project, just as it could before it was encoded.&lt;br /&gt;
&lt;br /&gt;
This can be done in two ways. This is Method 1:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
define load data (data)&lt;br /&gt;
set [i v] to [1] //&amp;quot;i&amp;quot; is used so the system knows which letter it&amp;#039;s reading.&lt;br /&gt;
set [value v] to []//We&amp;#039;ll add this to a list.&lt;br /&gt;
repeat until &amp;lt;(i) &amp;gt; (length of (data))&amp;gt;//Start reading.&lt;br /&gt;
repeat until &amp;lt;(letter (i) of (data)) = [;]&amp;gt;//Read letter by letter.&lt;br /&gt;
set [value v] to (join (value) (letter (i) of (data)))&lt;br /&gt;
change [i v] by (1)//So the system doesn&amp;#039;t stick at one letter.&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;not &amp;lt;(value) = []&amp;gt;&amp;gt; then//Skips saving blank values, making it easier to tell which list item is which&lt;br /&gt;
add (value) to [Loaded Data v]//So we can actually read the loaded value.&lt;br /&gt;
end&lt;br /&gt;
change [i v] by (1)&lt;br /&gt;
set [value v] to []//Reset&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively, Method 2:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
define load data (data) with the character (character)&lt;br /&gt;
set [letter # v] to (1)&lt;br /&gt;
delete all of [decoded v]&lt;br /&gt;
repeat(length of (data))&lt;br /&gt;
if&amp;lt;(letter(letter #)of(data))=(character)&amp;gt; then&lt;br /&gt;
add () to [decoded v]&lt;br /&gt;
else&lt;br /&gt;
replace item (length of [decoded v]:: list) of [decoded v] with (join(item(length of [decoded v]::list) of [decoded v])(letter(letter #) of (data))&lt;br /&gt;
end&lt;br /&gt;
change [letter # v] by (1)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here&amp;#039;s an example of Method 1 in action:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when flag clicked&lt;br /&gt;
set [code v] to ()&lt;br /&gt;
when [l v] key pressed&lt;br /&gt;
ask [Save code?] and wait&lt;br /&gt;
load (answer) :: custom&lt;br /&gt;
set [level v] to (item (1) of [Loaded Data v])// order of loading&lt;br /&gt;
set [coins v] to (item (2) of [Loaded Data v])&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
In this example, pressing the L key will load the &amp;quot;level&amp;quot; and &amp;quot;coins&amp;quot; variables from the encoded data.&lt;br /&gt;
&lt;br /&gt;
===Encrypting Save Codes===&lt;br /&gt;
&lt;br /&gt;
The user can easily cheat by entering the desired values into the save code (e.g. they&amp;#039;ll write &amp;quot;9999; 9999;&amp;quot; into the save code so &amp;quot;level&amp;quot; and &amp;quot;coins&amp;quot; will be 9999 rather than getting those values in the project) also known as &amp;quot;hacking&amp;quot; the save code, encrypting it may be necessary.&lt;br /&gt;
&lt;br /&gt;
{{note|This method is designed only for saving numbers, not letters or symbols.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
define save (data)&lt;br /&gt;
set [code v] to (join(join (code) [; ]) ((data) * [43653]))&lt;br /&gt;
when flag clicked&lt;br /&gt;
set [code v] to ()&lt;br /&gt;
when [s v] key pressed&lt;br /&gt;
save (level) :: custom blocks&lt;br /&gt;
save (coins) :: custom blocks&lt;br /&gt;
define load data (data)&lt;br /&gt;
set [i v] to [1]&lt;br /&gt;
set [value v] to []&lt;br /&gt;
repeat until &amp;lt;(i) &amp;gt; (length of (data))&amp;gt;&lt;br /&gt;
repeat until &amp;lt;(letter (i) of (data)) = [;]&amp;gt;&lt;br /&gt;
set [value v] to (join (value) (letter (i) of (data)))&lt;br /&gt;
change [i v] by (1)&lt;br /&gt;
end&lt;br /&gt;
add ((value) / (43653)) to [Loaded Data v]//So it encodes it right.&lt;br /&gt;
change [i v] by (1)&lt;br /&gt;
set [value v] to []&lt;br /&gt;
end&lt;br /&gt;
when [l v] key pressed&lt;br /&gt;
ask [Save code?] and wait&lt;br /&gt;
load (answer) :: custom blocks&lt;br /&gt;
set [level v] to (item (1) of [Loaded Data v])&lt;br /&gt;
set [coins v] to (item (2) of [Loaded Data v])&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That was an encrypted save data system which works by encoding and decoding the variables &amp;quot;level&amp;quot; and &amp;quot;coins&amp;quot;.&lt;br /&gt;
{{note|Please do not use random numbers as proven in this [[projects:488755346|here]].}}&lt;br /&gt;
[[Category:Variables and List Tutorials]]&lt;br /&gt;
[[Category:Scripting Tutorials]]&lt;/div&gt;</summary>
		<author><name>scratch&gt;TemplatesFTW</name></author>
	</entry>
</feed>