You don't.
On a project, you mean?
Last edited by mythbusteranimator (2012-10-31 10:01:49)
Offline
Ideas wrote:
ON a project is it possible to make a varible/list which tells you how many scratchers are viewing the project.
No.
Offline
Just curious, is the script allowed to use Scratxh 2.0 features to figure out who's online? If yes, then I'll be able to get you a script. If not, well I can't.
Offline
Ideas wrote:
Yes, actually, because i want to create a game where you play with all the online scratchers.
I had posted it on another we page for safe keeping, except the page refreshed, so I'll get the script to you in several minutes.
Edit: Also, do you want the scripts to say who's online?
Last edited by ErnieParke (2012-10-31 16:53:52)
Offline
Ideas wrote:
If that is possible then yes
And it is possible. Anyway, I'll get your scripts to you in about 10~20 minutes.
Offline
This isn't 100% flawless, but these scripts will work. First, make 2~3 variables and two lists:
Variables:
(Cloud)Timer*
(Cloud)Timer-
Memory//Opptional
List:
(Cloud)Online
(Cloud)Anonymous
Here are the scripts:
when gf clicked
if <not<(user ID) = (0)>>
add (user ID) to [online v]
if <(timer*) = ()>
set [timer- v] to (0)
delete [all v] of [online v]
delete [all v] of [Anonymous v]
add (user ID) to [online v]
set [timer* v] to [-]
wait (3) secs//Time for cloud variables to update.
set [timer* v] to (item [any v] of [online v])
end
else
add [User] to [Anonymous v]
end
forever
if <(timer*) = (User ID)>
wait (.98) secs
change [timer- v] by (1)
if <(timer-) = (8)>//The delay between updates. Adjust it if you want.
set [timer- v] to (0)
delete [all v] of [online v]
delete [all v] of [Anonymous v]
add (user ID) to [online v]
set [timer* v] to [-]
wait (3) secs//Time for cloud variables to update.
Fillet.//You might have to edit the 2 to make this work.
set [timer* v] to (item [any v] of [online v])
end
end
when gf clicked
forever
if <(timer*) = [-]>
if <not<(user ID) = (0)>>
if <not <[online v] contains (userID)>>
add (user ID) to [online v]
end
else
add [User] to [Anonymous v]
wait until <not <(timer*) = [-]>>
end
end
when gf clicked
forever//Use this script or...
set [memory v] to (timer-)
wait (5) secs
if <<(memory) = (timer-)> and <not <(timer*) = [-]>>>
set [timer- v] to (0)
delete [all v] of [online v]
delete [all v] of [Anonymous v]
add (user ID) to [online v]
set [timer* v] to [-]
wait (3) secs
set [timer* v] to (item [any v] of [online v])
end
when gf clicked
forever//…this script.
if <(ping) = [true]>//Replace with what you'll use to detect…
Fillet.//…when you're rechecking who's online.
Fillet.//For example, you might use a button.
if <not <(timer*) = [-]>>
set [timer- v] to (0)
delete [all v] of [online v]
delete [all v] of [Anonymous v]
add (user ID) to [online v]
set [timer* v] to [-]
wait (3) secs
set [timer* v] to (item [any v] of [online v])
end
end
The third script might not work if the delay for updating cloud variables is big enough, in which case you'll have to use the fourth script in place of the third. Also, once you've implemented this script, the list Online should become which scratchers are viewing your project and the list Anonymous should be the non-scratchers viewing the project. Add their lengths to get how many people are viewing your project.Last edited by ErnieParke (2012-11-01 17:13:51)
Offline
Ideas wrote:
What is user id's initial value?
Used ID is a new variable in Scratch 2.0 that reports the viewer # of a viewer, except when the viewer isn't a scratcher, which then it reports 0. So in other words, user ID's initial value is preset for you.
Offline