Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make scripts work only if someone has never played the game before?
- Red_PC_AltAccount
-
Scratcher
37 posts
How to make scripts work only if someone has never played the game before?
Yes, I know.
This is a repost.
Turns out I put the og one in questions about scratch so I realized I would get more help if I put it here. So….how to make certain things happen if the player has never actually “clicked green flag”
This is a repost.
Turns out I put the og one in questions about scratch so I realized I would get more help if I put it here. So….how to make certain things happen if the player has never actually “clicked green flag”
when green flag clicked
set [what v] to true
- ScolderCreations
-
Scratcher
1000+ posts
How to make scripts work only if someone has never played the game before?
One way to accomplish this is to make a variable that is set something by default, but once you click the green flag, it changes and doesn't reset. You can do this by changing the variable to something, then saving the project. Every time someone runs the project, it'll change the variable, but if they refresh the page, it'll change back.
- Doriok
-
Scratcher
82 posts
How to make scripts work only if someone has never played the game before?
For simplicity, I'd suggest having a public list in which you add the username of the client, and have a condition to execute code when the client's username is not yet in the list:
when green flag clicked
if <not <[Users v] contains (username) ?>> then
Your code...
end
add (username) to [Users v]
- Thingied
-
Scratcher
1000+ posts
How to make scripts work only if someone has never played the game before?
For simplicity, I'd suggest having a public list in which you add the username of the client, and have a condition to execute code when the client's username is not yet in the list:That won't work because the list won't save.when green flag clicked
if <not <[Users v] contains (username) ?>> then
Your code...
end
add (username) to [Users v]
Last edited by Thingied (July 23, 2021 22:36:39)
- cIoudyness
-
Scratcher
500+ posts
How to make scripts work only if someone has never played the game before?
cloud lists? for example, griffpatch's hill climb racing leaderboard list? it's possible, but to be honest I don't think it's worth the effort (and you realistically can only save 100 places)
- Red_PC_AltAccount
-
Scratcher
37 posts
How to make scripts work only if someone has never played the game before?
cloud lists? for example, griffpatch's hill climb racing leaderboard list? it's possible, but to be honest I don't think it's worth the effort (and you realistically can only save 100 places)Yeah that’s an idea! (Yes I know that’s 80s. So sue me.)
- Red_PC_AltAccount
-
Scratcher
37 posts
How to make scripts work only if someone has never played the game before?
cloud lists? for example, griffpatch's hill climb racing leaderboard list? it's possible, but to be honest I don't think it's worth the effort (and you realistically can only save 100 places)Also I have a cloud in my backpack
- Yusei-Fudo
-
Scratcher
1000+ posts
How to make scripts work only if someone has never played the game before?
cloud lists? for example, griffpatch's hill climb racing leaderboard list? it's possible, but to be honest I don't think it's worth the effort (and you realistically can only save 100 places)
I'm sorry, but that really won't work either. Here's why:
First, logging every viewers' usernames is really impossible on Scratch. Even considering that each cloud variables can contain 256 numbers and you have ten of them, you would only be able to save 2,560 numbers. And let's say somehow that you have only 10-letter-long usernames that use your projects, you would only be able to save 256 users. What if you have only 11-letter-long usernames? What if you become famous like griffpatch who shared a default project (no scripts, just Scratch Cat on a blank white stage, and even the project name is default! The name was Untitled-1) on Aprils Fools day, which literally got 5000+ views like 1-2 days after he shared the project, then what? You'd have no more cloud storage room right?
Second, let's say that you don't manage to become famous and get a lot of views on that project, what if a NEW SCRATCHER or a NON-SIGNED IN user uses it? Then how are you going to counter that?
- Eagle138
-
Scratcher
500+ posts
How to make scripts work only if someone has never played the game before?
Maybe you could ask them first at the start of the game? (like 'when flag clicked > ask “Have you played before” and wait)
- Yusei-Fudo
-
Scratcher
1000+ posts
How to make scripts work only if someone has never played the game before?
Maybe you could ask them first at the start of the game? (like 'when flag clicked > ask “Have you played before” and wait)
That only works on honest people. Does take a bit effect though.
- Red_PC_AltAccount
-
Scratcher
37 posts
How to make scripts work only if someone has never played the game before?
Maybe you could ask them first at the start of the game? (like 'when flag clicked > ask “Have you played before” and wait)
I mean, I guess…I could:
when green flag clickedBut I don’t think it’s very effective
ask [have you played?] and wait
if <[answer] = [no]> then
if <[cloud v] contains [(username)] ?> then
broadcast [played v]
end
end
- -EmeraldThunder-
-
Scratcher
1000+ posts
How to make scripts work only if someone has never played the game before?
You can set up a python or node.js server to write the username of the people who have played to a JSON file. If when someone presses the flag search the JSON data for their username and return either 0 or 1 depending on the outcome of the search function.
- orangetheory
-
Scratcher
500+ posts
How to make scripts work only if someone has never played the game before?
This is fairly easy, idk why so many people are bickering over about it, no offense.
when green flag clicked
change [Viewed? v] by (1)
in a separate script::pen
when green flag clicked
if <(Viewed) > [1]> then
say [you have already viewed this project!]
stop [all v]
else
Your game code here
end
- Thingied
-
Scratcher
1000+ posts
How to make scripts work only if someone has never played the game before?
This is fairly easy, idk why so many people are bickering over about it, no offense.That doesn't work because it doesn't save. Sure, it might save when the owner is doing and saving the project but it won't for other people. Also, if it did save, the project would think that everyone has played the project.when green flag clicked
change [Viewed? v] by (1)
in a separate script::pen
when green flag clicked
if <(Viewed) > [1]> then
say [you have already viewed this project!]
stop [all v]
else
Your game code here
end
- cIoudyness
-
Scratcher
500+ posts
How to make scripts work only if someone has never played the game before?
This is fairly easy, idk why so many people are bickering over about it, no offense.when green flag clicked
change [Viewed? v] by (1)
in a separate script::pen
when green flag clicked
if <(Viewed) > [1]> then
say [you have already viewed this project!]
stop [all v]
else
Your game code here
end
it would be a good idea to first test your ideas for practicality and effectiveness before promoting them to others. the problem with this solution is that it's useless when a user refreshes
- Red_PC_AltAccount
-
Scratcher
37 posts
How to make scripts work only if someone has never played the game before?
That's honestly a great idea, but I don't know if this will work:This is fairly easy, idk why so many people are bickering over about it, no offense.That doesn't work because it doesn't save. Sure, it might save when the owner is doing and saving the project but it won't for other people. Also, if it did save, the project would think that everyone has played the project.when green flag clicked
change [Viewed? v] by (1)
in a separate script::pen
when green flag clicked
if <(Viewed) > [1]> then
say [you have already viewed this project!]
stop [all v]
else
Your game code here
end
when green flag clickedBut this is really old and I don't need it anymore because I simply created a save code.
if < (played) < (cloud players)> then
set [played v] to (players)
else
broadcast [played v]
end
- jD2R
-
Scratcher
24 posts
How to make scripts work only if someone has never played the game before?
I would say just use a cloud list or even a regular list, and if the list contains the username then don't show the instructions or whatever.
- Thingied
-
Scratcher
1000+ posts
How to make scripts work only if someone has never played the game before?
I would say just use a cloud list or even a regular list, and if the list contains the username then don't show the instructions or whatever.1. Cloud lists are very limited in how much information they can store
2. Regular lists won't save for everyone
Last edited by Thingied (July 28, 2021 17:29:17)
- Discussion Forums
- » Help with Scripts
-
» How to make scripts work only if someone has never played the game before?