<?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=Global_High_Scores</id>
	<title>Global High Scores - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=Global_High_Scores"/>
	<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Global_High_Scores&amp;action=history"/>
	<updated>2026-05-06T11:31:42Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Global_High_Scores&amp;diff=32620&amp;oldid=prev</id>
		<title>Patarakin: /* Encoding */</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Global_High_Scores&amp;diff=32620&amp;oldid=prev"/>
		<updated>2025-10-10T04:30:32Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Encoding&lt;/span&gt;&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;Версия от 07:30, 10 октября 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l51&quot;&gt;Строка 51:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Строка 51:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Encoding is the process by which users and their data are formatted into a sequence of numbers in the cloud variable &amp;quot;{{^}} leaderboard&amp;quot;. First, consider the following lists:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Encoding is the process by which users and their data are formatted into a sequence of numbers in the cloud variable &amp;quot;{{^}} leaderboard&amp;quot;. First, consider the following lists:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[File:Data Compare.png]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each user&amp;#039;s data is linked to their score. The scores&amp;#039; numerical placement can be accomplished through scripts outside the encoding and decoding. Using this data linkage, the cloud variable encoder can go one-by-one to add each username and score in number format to &amp;quot;{{^}} leaderboard&amp;quot;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each user&amp;#039;s data is linked to their score. The scores&amp;#039; numerical placement can be accomplished through scripts outside the encoding and decoding. Using this data linkage, the cloud variable encoder can go one-by-one to add each username and score in number format to &amp;quot;{{^}} leaderboard&amp;quot;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key digida:diff:1.41:old-32619:rev-32620:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Global_High_Scores&amp;diff=32619&amp;oldid=prev</id>
		<title>Patarakin в 04:30, 10 октября 2025</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Global_High_Scores&amp;diff=32619&amp;oldid=prev"/>
		<updated>2025-10-10T04:30:06Z</updated>

		<summary type="html">&lt;p&gt;&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;Версия от 07:30, 10 октября 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Строка 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Строка 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Cloud Data}}&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{about|global high scores, although it focuses on encoding and decoding|strictly encoding and decoding|Encoding and Decoding Cloud Data}}&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;With the new [[Cloud Variables|cloud variable]] feature in [[Scratch 2.0]], &amp;#039;&amp;#039;&amp;#039;global high score&amp;#039;&amp;#039;&amp;#039; lists can be made within a project. These high score lists, stored inside a cloud [[variable]], can take only seconds to update. This tutorial explains how to code a fully functional global high score list, so users&amp;#039; data can be saved for a particular project.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;With the new [[Cloud Variables|cloud variable]] feature in [[Scratch 2.0]], &amp;#039;&amp;#039;&amp;#039;global high score&amp;#039;&amp;#039;&amp;#039; lists can be made within a project. These high score lists, stored inside a cloud [[variable]], can take only seconds to update. This tutorial explains how to code a fully functional global high score list, so users&amp;#039; data can be saved for a particular project.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{note|Though this focuses on high scores, this information can also be relevant to any user-saved data.}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{note|Though this focuses on high scores, this information can also be relevant to any user-saved data.}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l227&quot;&gt;Строка 227:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Строка 225:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Scripting Tutorials]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Scripting Tutorials]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[fr:Scratch Wiki Accueil/tutos/013 ajouter highscore]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Global_High_Scores&amp;diff=1688&amp;oldid=prev</id>
		<title>Patarakin: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Global_High_Scores&amp;diff=1688&amp;oldid=prev"/>
		<updated>2022-07-21T08:33:14Z</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;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;1&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;2&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;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Global_High_Scores&amp;diff=1687&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=Global_High_Scores&amp;diff=1687&amp;oldid=prev"/>
		<updated>2021-12-29T11:51:31Z</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;{{Cloud Data}}&lt;br /&gt;
{{about|global high scores, although it focuses on encoding and decoding|strictly encoding and decoding|Encoding and Decoding Cloud Data}}&lt;br /&gt;
With the new [[Cloud Variables|cloud variable]] feature in [[Scratch 2.0]], &amp;#039;&amp;#039;&amp;#039;global high score&amp;#039;&amp;#039;&amp;#039; lists can be made within a project. These high score lists, stored inside a cloud [[variable]], can take only seconds to update. This tutorial explains how to code a fully functional global high score list, so users&amp;#039; data can be saved for a particular project.&lt;br /&gt;
{{note|Though this focuses on high scores, this information can also be relevant to any user-saved data.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Simple high score==&lt;br /&gt;
For a simple one that shows the highest score, two variables can be used:&lt;br /&gt;
* &amp;lt;sb&amp;gt;(score)&amp;lt;/sb&amp;gt;&lt;br /&gt;
* &amp;lt;sb&amp;gt;(☁ high score)&amp;lt;/sb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following script can then be created:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
forever&lt;br /&gt;
if &amp;lt;(score) &amp;gt; (☁ high score)&amp;gt; then&lt;br /&gt;
set [☁ high score v] to (score)&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{note|This script shows only the highest score, not the username of the person who set it.}}&lt;br /&gt;
&lt;br /&gt;
==Automatically Resetting Scores==&lt;br /&gt;
If you want the Global High Score of a game to be reset automatically throughout a period of time so that everyone gets a chance, you can use a script like this one:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
hide variable [☁ Auto Reset v]&lt;br /&gt;
forever&lt;br /&gt;
if &amp;lt;not &amp;lt;(☁ Auto Reset) = (([floor v] of (days since 2000)::operators)*(number of wanted time in a day::grey))&amp;gt;&amp;gt; then&lt;br /&gt;
set [☁ Auto Reset v] to (([floor v] of (days since 2000)::operators)*(number of wanted time in a day::grey))&lt;br /&gt;
set [☁ High Score v] to [0]&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
Since cloud [[list]]s are rejected, programming this functionality can be quite difficult. Users&amp;#039; data has to be saved in cloud &amp;#039;&amp;#039;variables&amp;#039;&amp;#039;, with a limitation: only numbers can be stored. The [[Scratch Team]] currently does not allow letters within cloud variables for security reasons. Therefore, scripts are needed to encode and decode the data into sequences of numbers. This tutorial requires the use of:&lt;br /&gt;
* Three lists&lt;br /&gt;
** &amp;lt;sb&amp;gt;letter::list reporter&amp;lt;/sb&amp;gt;&lt;br /&gt;
** &amp;lt;sb&amp;gt;users::list reporter&amp;lt;/sb&amp;gt;&lt;br /&gt;
** &amp;lt;sb&amp;gt;scores::list reporter&amp;lt;/sb&amp;gt;&lt;br /&gt;
* Nine variables&lt;br /&gt;
** &amp;lt;sb&amp;gt;(score)&amp;lt;/sb&amp;gt;&lt;br /&gt;
** &amp;lt;sb&amp;gt;(letter#)&amp;lt;/sb&amp;gt;&lt;br /&gt;
** &amp;lt;sb&amp;gt;(letter detect)&amp;lt;/sb&amp;gt;&lt;br /&gt;
** &amp;lt;sb&amp;gt;(list item)&amp;lt;/sb&amp;gt;&lt;br /&gt;
** &amp;lt;sb&amp;gt;(i)&amp;lt;/sb&amp;gt;&lt;br /&gt;
** &amp;lt;sb&amp;gt;(☁ leaderboard)&amp;lt;/sb&amp;gt;&lt;br /&gt;
** &amp;lt;sb&amp;gt;(v1)&amp;lt;/sb&amp;gt;&lt;br /&gt;
** &amp;lt;sb&amp;gt;item::variables reporter&amp;lt;/sb&amp;gt;&lt;br /&gt;
** &amp;lt;sb&amp;gt;chars::variables reporter&amp;lt;/sb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Encoding==&lt;br /&gt;
Encoding is the process by which users and their data are formatted into a sequence of numbers in the cloud variable &amp;quot;{{^}} leaderboard&amp;quot;. First, consider the following lists:&lt;br /&gt;
&lt;br /&gt;
[[File:Data Compare.png]]&lt;br /&gt;
&lt;br /&gt;
Each user&amp;#039;s data is linked to their score. The scores&amp;#039; numerical placement can be accomplished through scripts outside the encoding and decoding. Using this data linkage, the cloud variable encoder can go one-by-one to add each username and score in number format to &amp;quot;{{^}} leaderboard&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
During the encoding process, each character or number in a list item is represented by a two-digit number. For example, &amp;quot;a&amp;quot; would be the digit &amp;quot;01&amp;quot; and &amp;quot;b&amp;quot; the digit &amp;quot;02&amp;quot;. The list &amp;quot;characters&amp;quot; stores as many as 99 characters to encode. If there were 100 or more characters readable by the global high score system, each character would have to be represented by a three-digit value. The order the characters go in this list does not matter; they just have to be consistent throughout the encoding process.&lt;br /&gt;
&lt;br /&gt;
Therefore, each list item (i.e. a user and their score) is separated by &amp;quot;00&amp;quot;. Without it, the script could not separate the list items properly, and all the characters would be a large jumble.&lt;br /&gt;
&lt;br /&gt;
After the list is filled out with available computer characters, the cloud variable encoding script can be made. It is a long process encoding the data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
define encode&lt;br /&gt;
set [list item v] to [1]&lt;br /&gt;
set [v1 v] to []&lt;br /&gt;
repeat (length of [users v])&lt;br /&gt;
    set [letter detect v] to [1]&lt;br /&gt;
    set [letter# v] to [1]&lt;br /&gt;
    repeat (length of (item (list item) of [users v]))&lt;br /&gt;
        set [letter detect v] to [1]&lt;br /&gt;
        repeat until &amp;lt;(letter (letter#) of (item (list item) of [users v])) = (item (letter detect) of [letter v])&amp;gt;&lt;br /&gt;
            change [letter detect v] by (1)&lt;br /&gt;
        end&lt;br /&gt;
        if &amp;lt;(letter detect) &amp;lt; [10]&amp;gt; then&lt;br /&gt;
            set [v1 v] to (join (v1) (join [0] (letter detect)))&lt;br /&gt;
        else&lt;br /&gt;
            set [v1 v] to (join (v1) (letter detect))&lt;br /&gt;
        end&lt;br /&gt;
        change [letter# v] by (1)&lt;br /&gt;
    end&lt;br /&gt;
    set [v1 v] to (join (v1) [00])&lt;br /&gt;
    set [letter detect v] to [1]&lt;br /&gt;
    set [letter# v] to [1]&lt;br /&gt;
    repeat (length of (item (list item) of [scores v]))&lt;br /&gt;
        set [letter detect v] to [1]&lt;br /&gt;
        repeat until &amp;lt;(letter (letter#) of (item (list item) of [scores v])) = (item (letter detect) of [letter v])&amp;gt;&lt;br /&gt;
            change [letter detect v] by (1)&lt;br /&gt;
        end&lt;br /&gt;
        if &amp;lt;(letter detect) &amp;lt; [10]&amp;gt; then&lt;br /&gt;
            set [v1 v] to (join (v1) (join [0] (letter detect)))&lt;br /&gt;
        else&lt;br /&gt;
            set [v1 v] to (join (v1) (letter detect))&lt;br /&gt;
        end&lt;br /&gt;
        change [letter# v] by (1)&lt;br /&gt;
    end&lt;br /&gt;
    set [v1 v] to (join (v1) [00])&lt;br /&gt;
    change [list item v] by (1)&lt;br /&gt;
end&lt;br /&gt;
set [☁ leaderboard v] to (v1)&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Decoding==&lt;br /&gt;
Decoding is the process by which the numerically encoded data is decoded, or taken out of number format and compiled into the two lists again. Decoding checks for the &amp;quot;00&amp;quot; placed between list items during the encoding to determine when to iterate to the next list item. After the process is complete, the lists will be arranged in the manner prior to the encoding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
define decode&lt;br /&gt;
set [letter# v] to [0]&lt;br /&gt;
set [letter detect v] to [1]&lt;br /&gt;
delete all of [users v]&lt;br /&gt;
delete all of [scores v]&lt;br /&gt;
add [] to [users v]&lt;br /&gt;
add [] to [scores v]&lt;br /&gt;
repeat until &amp;lt;(letter#) &amp;gt; ((length of (☁ leaderboard)) - (1))&amp;gt;&lt;br /&gt;
    repeat until &amp;lt;(join (letter ((letter#) + (1)) of (☁ leaderboard)) (letter ((letter#) + (2)) of (☁ leaderboard))) = [00]&amp;gt;&lt;br /&gt;
        set [letter detect v] to [1]&lt;br /&gt;
        repeat until &amp;lt;(letter detect) = (join (letter ((letter#) + (1)) of (☁ leaderboard)) (letter ((letter#) + (2)) of (☁ leaderboard)))&amp;gt;&lt;br /&gt;
            change [letter detect v] by (1)&lt;br /&gt;
            if &amp;lt;(letter detect) &amp;lt; [10]&amp;gt; then&lt;br /&gt;
                set [letter detect v] to (join [0] (letter detect))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if &amp;lt;(letter (1) of (letter detect)) = [0]&amp;gt; then&lt;br /&gt;
            set [letter detect v] to (letter (2) of (letter detect))&lt;br /&gt;
        end&lt;br /&gt;
        replace item (last v) of [users v] with (join (item (last v) of [users v]) (item (letter detect) of [letter v]))&lt;br /&gt;
        change [letter# v] by (2)&lt;br /&gt;
    end&lt;br /&gt;
    change [letter# v] by (2)&lt;br /&gt;
    repeat until &amp;lt;(join (letter ((letter#) + (1)) of (☁ leaderboard)) (letter ((letter#) + (2)) of (☁ leaderboard))) = [00]&amp;gt;&lt;br /&gt;
        set [letter detect v] to [1]&lt;br /&gt;
        repeat until &amp;lt;(letter detect) = (join (letter ((letter#) + (1)) of (☁ leaderboard)) (letter ((letter#) + (2)) of (☁ leaderboard)))&amp;gt;&lt;br /&gt;
            change [letter detect v] by (1)&lt;br /&gt;
        end&lt;br /&gt;
        replace item (last v) of [scores v] with (join (item (last v) of [scores v]) (item (letter detect) of [letter v]))&lt;br /&gt;
        change [letter# v] by (2)&lt;br /&gt;
    end&lt;br /&gt;
    add [] to [users v]&lt;br /&gt;
    add [] to [scores v]&lt;br /&gt;
    change [letter# v] by (2)&lt;br /&gt;
end&lt;br /&gt;
delete (length of [users v]) of [users v]&lt;br /&gt;
delete (length of [users v]) of [scores v]&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Adding and Replacing Scores==&lt;br /&gt;
When adding and replacing the scores in the lists, a variable is needed to iterate through the&lt;br /&gt;
list to the correct numerical placement. If the high score leaderboards (consisting of the list &amp;quot;users&amp;quot; and &amp;quot;scores&amp;quot;) does not contain the user running the project, their username and score will be added to the lists at the beginning of a project. The following script can replicate this situation:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
delete all of [letter v]&lt;br /&gt;
set [chars v] to [� !&amp;quot;#$%&amp;amp;&amp;#039;()*+,-./:;&amp;lt;=&amp;gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~0123456789&lt;br /&gt;
set [item v] to (1)&lt;br /&gt;
repeat (length of (chars::variables))&lt;br /&gt;
add (letter (item) of (chars::variables)) to [letter v]&lt;br /&gt;
change [item v] by [1]&lt;br /&gt;
end&lt;br /&gt;
decode::custom&lt;br /&gt;
if &amp;lt;&amp;lt;not &amp;lt;(username) = []&amp;gt;&amp;gt;and&amp;lt;not&amp;lt;[users v] contains (username)?&amp;gt;&amp;gt;&amp;gt; then //checks if the user is logged in to Scratch and not in the leaderboard&lt;br /&gt;
add (username) to [users v]&lt;br /&gt;
add [0] to [scores v] //in which &amp;quot;0&amp;quot; is the initial score&lt;br /&gt;
encode::custom&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
The example above shows how to add a completely new user to the leaderboards. What if the user is already in the leaderboards but had reached a higher score? To replace a user&amp;#039;s current high score with a new one, the current high score must first be deleted. Then, the new high score can be added to the list by iterating down the list with a variable until the score is greater than the one being analyzed. The following script performs this function:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
define change leaderboard&lt;br /&gt;
decode::custom&lt;br /&gt;
if &amp;lt;[users v] contains (username)&amp;gt; then //checks if the user has been added to the leaderboard already&lt;br /&gt;
set [i v] to [1] //begin with the first list item&lt;br /&gt;
repeat until &amp;lt;(item (i) of [users v]) = (username)&amp;gt; //the deletion process&lt;br /&gt;
change [i v] by (1)&lt;br /&gt;
end&lt;br /&gt;
delete (i) of [users v]&lt;br /&gt;
delete (i) of [scores v]&lt;br /&gt;
set [i v] to [1]&lt;br /&gt;
repeat until &amp;lt;&amp;lt;(i) &amp;gt; (length of [scores v])&amp;gt; or &amp;lt;(score) &amp;gt; (item (i) of [scores v])&amp;gt;&amp;gt; //the variable &amp;quot;score&amp;quot; is the latest score of the user&lt;br /&gt;
change [i v] by (1) //it will end at the proper list location&lt;br /&gt;
end&lt;br /&gt;
insert (username) at (i) of [users v]&lt;br /&gt;
insert (score) at (i) of [scores v]&lt;br /&gt;
encode::custom&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
Then, use this:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
delete all of [letter v]&lt;br /&gt;
set [chars v] to [� !&amp;quot;#$%&amp;amp;&amp;#039;()*+,-./:;&amp;lt;=&amp;gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~0123456789&lt;br /&gt;
set [item v] to (1)&lt;br /&gt;
repeat (length of(chars::variables))&lt;br /&gt;
add (letter (item) of (chars::variables)) to [letter v]&lt;br /&gt;
change [item v] by [1]&lt;br /&gt;
end&lt;br /&gt;
decode::custom&lt;br /&gt;
if &amp;lt;&amp;lt;not &amp;lt;(username) = []&amp;gt;&amp;gt;and&amp;lt;not&amp;lt;[users v] contains (username)?&amp;gt;&amp;gt;&amp;gt; then //checks if the user is logged in to Scratch and not in the leaderboard&lt;br /&gt;
add (username) to [users v]&lt;br /&gt;
add [0] to [scores v] //in which &amp;quot;0&amp;quot; is the initial score&lt;br /&gt;
encode::custom&lt;br /&gt;
end&lt;br /&gt;
forever&lt;br /&gt;
change leaderboard::custom&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Avoiding Interference==&lt;br /&gt;
When encoding (saving) the data stored in the lists, the cloud [[variable]]s can take about two seconds to update. If multiple people happen to be encoding at the same time, glitches could occur which cause the data to become broken, changed, or deleted. Also, any disrupted data in the encoder can sometimes cause an [[wikipedia:Infinite loop|infinite loop]] in the decoder, though scripts can be used to prevent that. These issues are particularly more likely to occur on a very popular project with tons of data to be encoded. To prevent any such encoding interference from destroying a leaderboard, saving back-ups of the lists often can be very useful.&lt;br /&gt;
&lt;br /&gt;
A script to prevent that can be made but takes time if it is to have a low margin for error. Create a custom block called &amp;#039;wait and encode&amp;#039;. Also, create another cloud variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sb&amp;gt;(☁ queue)&amp;lt;/sb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
define wait and encode&lt;br /&gt;
repeat until &amp;lt;(☁ queue) = (0)&amp;gt;&lt;br /&gt;
wait until &amp;lt;(☁ queue) = [0]&amp;gt;&lt;br /&gt;
wait (pick random (1) to (5)) secs&lt;br /&gt;
end&lt;br /&gt;
set [☁ queue v] to (1)&lt;br /&gt;
encode::custom&lt;br /&gt;
set [☁ queue v] to (0)&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The higher the second bound of the random wait, the less margin for error there is. What can happen is two computers can still try to encode simultaneously but there is less chance this way.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting Tutorials]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Scratch Wiki Accueil/tutos/013 ajouter highscore]]&lt;/div&gt;</summary>
		<author><name>scratch&gt;TemplatesFTW</name></author>
	</entry>
</feed>