This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-03-19 20:01:20

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Timeout Mesh Script

I was trying to design a script to detect when a player disconnects from Mesh. I made one but it isn't very efficient when a high number of players go online. My script involved a variable that is constantly changed by -1 when a player joins the mesh. The player who joined continously broadcasts "Renew" and when "Renew" is received, the variable is changed back to 20. When the variable reaches 0, the player is disconnected. Is this the only way? Or is there a more efficient method? Thanks a lot!

Offline

 

#2 2012-03-19 20:57:21

Luke121
Scratcher
Registered: 2008-07-14
Posts: 1000+

Re: Timeout Mesh Script

I'd try using a shared list.


http://bit.ly/IlVuB5
Sorry PF, too lazy to make my own!  tongue

Offline

 

#3 2012-03-19 20:58:19

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Timeout Mesh Script

itsmomito wrote:

I was trying to design a script to detect when a player disconnects from Mesh. I made one but it isn't very efficient when a high number of players go online. My script involved a variable that is constantly changed by -1 when a player joins the mesh. The player who joined continously broadcasts "Renew" and when "Renew" is received, the variable is changed back to 20. When the variable reaches 0, the player is disconnected. Is this the only way? Or is there a more efficient method? Thanks a lot!

Since Scratch doesn't tell the project that a user has disconnected or joined, that is probably the best way. You could infinitely check a sensor-value to see if it's not 0. Though I think Scratch retains the oldest value of the sensor-value, so that probably wouldn't work.

Offline

 

#4 2012-03-20 00:51:10

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Re: Timeout Mesh Script

Ahh, okay. Thank you

Offline

 

Board footer