<?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=Sending_Cloud_Data_Signals</id>
	<title>Sending Cloud Data Signals - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=Sending_Cloud_Data_Signals"/>
	<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Sending_Cloud_Data_Signals&amp;action=history"/>
	<updated>2026-04-30T18:28:43Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Sending_Cloud_Data_Signals&amp;diff=1760&amp;oldid=prev</id>
		<title>Patarakin: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Sending_Cloud_Data_Signals&amp;diff=1760&amp;oldid=prev"/>
		<updated>2022-07-21T08:33:15Z</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-1759:rev-1760 --&gt;
&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Sending_Cloud_Data_Signals&amp;diff=1759&amp;oldid=prev</id>
		<title>scratch&gt;PenguinLover1123: /* Using Four Cloud Variables */ change</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Sending_Cloud_Data_Signals&amp;diff=1759&amp;oldid=prev"/>
		<updated>2021-07-01T13:23:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Using Four Cloud Variables: &lt;/span&gt; change&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Cloud Data}}&lt;br /&gt;
[[Project]]s which use [[Cloud Data]] may have to send &amp;#039;&amp;#039;&amp;#039;signals&amp;#039;&amp;#039;&amp;#039; from one player to another. The scenario explained in this article is when a project can only continue when all players are ready – they therefore need to send signals to each other, which can be more complicated than it sounds for someone who is new to cloud data. The examples use a [[Game Projects|game]] which connects three players.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Using One Cloud Variable==&lt;br /&gt;
{{note|This method should not be used. It is only given to illustrate why a more complex approach is necessary.}}&lt;br /&gt;
&lt;br /&gt;
===How to Do It===&lt;br /&gt;
&lt;br /&gt;
This section assumes that the project has a cloud [[variable]] named &amp;lt;sb&amp;gt;(☁ wait)&amp;lt;/sb&amp;gt; and that this variable is initially set to 0. When the player has reached a certain stage in the project and is therefore ready to continue, it changes the variable by one. It then waits until the variable is equal to the number of players (in this case 3), before the [[script]] continues:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
change [☁ wait v] by (1)&lt;br /&gt;
wait until &amp;lt;(☁ wait)=(3)&amp;gt; // Waits until all players have got to this stage&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Problems with This Method===&lt;br /&gt;
&lt;br /&gt;
Imagine that the variable is still 0 – none of the players a ready to continue yet. Then two players become ready very shortly after one another. The first player who is ready sees that the cloud variable is 0, and therefore sets it to 1. Before this has been uploaded to the [[Scratch]] server (there is always a short delay), the second player is ready. They also see the cloud variable to be 0 and therefore set it to 1. The server is told twice to set the variable to a value of 1, so even though two players are ready, the value remains 1. When the third player is ready, they set the variable to 2, and then all players continue waiting infinitely.&lt;br /&gt;
&lt;br /&gt;
==Using Three Cloud Variables And One Normal Variable==&lt;br /&gt;
{{note|This method should not be used. It is only given to illustrate why a more complex approach is necessary.}}&lt;br /&gt;
&lt;br /&gt;
===How to Do It===&lt;br /&gt;
&lt;br /&gt;
This section assumes that the project has 3 cloud variables (because of 3 players) named &amp;lt;sb&amp;gt;(☁ wait1)&amp;lt;/sb&amp;gt;, &amp;lt;sb&amp;gt;(☁ wait2)&amp;lt;/sb&amp;gt; and &amp;lt;sb&amp;gt;(☁ wait3)&amp;lt;/sb&amp;gt;, and that these variables are all initially set to 0. Each player also has a local variable called &amp;lt;sb&amp;gt;(mynumber)&amp;lt;/sb&amp;gt; which has a value form 1 to 3, depending on which player they are.&lt;br /&gt;
&lt;br /&gt;
When each player gets reaches this stage of the project, they change their own cloud variable (the one which corresponds to their number) by 1, and then wait until all the other players have done the same. This eliminates the problem in [[#Using One Cloud Variable|Method 1]] above where two players were changing the same variable at the same time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
if &amp;lt;(mynumber)=(1)&amp;gt; then&lt;br /&gt;
change [☁ wait1 v] by (1)&lt;br /&gt;
else&lt;br /&gt;
if &amp;lt;(mynumber)=(2)&amp;gt; then&lt;br /&gt;
change [☁ wait2 v] by (1)&lt;br /&gt;
else&lt;br /&gt;
if &amp;lt;(mynumber)=(3)&amp;gt; then&lt;br /&gt;
change [☁ wait3 v] by (1)&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
wait until &amp;lt;&amp;lt;(☁ wait1)=(1)&amp;gt; and &amp;lt;&amp;lt;(☁ wait2)=(1)&amp;gt; and &amp;lt;(☁ wait3)=(1)&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Problems with This Method===&lt;br /&gt;
&lt;br /&gt;
A problem can occur even here when there is a long delay from one of the players – this usually does not happen, but a script must always work, not just usually. Due to the limited number of cloud variables available in Scratch (10 per project), the variables will probably have to be reused in a cloud game soon after. Imagine that two players are already ready and have set their respective cloud variables to 1. Then the third player arrives and sets their cloud variable to 1. The other players continue, as all three variables equal 1, and give their own cloud variables new values. By the time the third player gets to the wait [[block]] (which could be several seconds later if there is a delay), the variables are no longer all equal to 1, and the third player once more waits infinitely.&lt;br /&gt;
&lt;br /&gt;
==Using Five Cloud Variables==&lt;br /&gt;
{{note|This is the method which should be used and is guaranteed to work.}}&lt;br /&gt;
&lt;br /&gt;
===How to Do It===&lt;br /&gt;
&lt;br /&gt;
This section assumes that the project has 4 cloud variables (3 players plus one extra) named &amp;lt;sb&amp;gt;(☁ wait1)&amp;lt;/sb&amp;gt;, &amp;lt;sb&amp;gt;(☁ wait2)&amp;lt;/sb&amp;gt;, &amp;lt;sb&amp;gt;(☁ wait3)&amp;lt;/sb&amp;gt; and &amp;lt;sb&amp;gt;(☁ globalwait)&amp;lt;/sb&amp;gt;, and that these variables are all initially set to 0. Again, each player also has a local variable called &amp;lt;sb&amp;gt;(mynumber)&amp;lt;/sb&amp;gt; which has a value form 1 to 3, depending on which player they are.&lt;br /&gt;
&lt;br /&gt;
When each player gets reaches this stage of the project, they change their own cloud variable (the one which corresponds to their number) by 1, and then wait until all the other players have done the same. This eliminates the problem in method 1 above where two players were changing the same variable at the same time.&lt;br /&gt;
&lt;br /&gt;
Once they have finished waiting, meaning that all players are indeed ready, they set the globalwait variable to 1. Then they can change their own cloud variables to anything they like, because globalwait acts as a signal to the final player. This solves the issue described in method 2 above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
if &amp;lt;(mynumber)=(1)&amp;gt; then&lt;br /&gt;
change [☁ wait1 v] by (1)&lt;br /&gt;
else&lt;br /&gt;
if &amp;lt;(mynumber)=(2)&amp;gt; then&lt;br /&gt;
change [☁ wait2 v] by (1)&lt;br /&gt;
else&lt;br /&gt;
if &amp;lt;(mynumber)=(3)&amp;gt; then&lt;br /&gt;
change [☁ wait3 v] by (1)&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
wait until &amp;lt;&amp;lt;(☁ globalwait)=(1)&amp;gt; or &amp;lt;&amp;lt;(☁ wait1)=(1)&amp;gt;and&amp;lt; &amp;lt;(☁ wait2)=(1)&amp;gt; and &amp;lt;(☁ wait3)=(1)&amp;gt;&amp;gt;&lt;br /&gt;
set[☁ globalwait v] to (1)&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method should work even if there is a 5-second delay between the players and every player is ready at the same time.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Cloud Data]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting Tutorials]]&lt;/div&gt;</summary>
		<author><name>scratch&gt;PenguinLover1123</name></author>
	</entry>
</feed>