Discuss Scratch

powercon5
Scratcher
1000+ posts

On page load

My suggestion is a hat black, on page load.

It would be used to play code when the page loads however when you re-press the green flag it does not activate again.

You could work around it by setting it to what you want and saving however if you want to test it you would have to reset it and save it again.
You could also work around it by having a variable for number of times played but you would have to reset that everytime you play it.

This is something simple but would be helpful.

The only problem with it could be that it can be used to start the game before the green flag and the only problem with that would be making a game harder and doing that would just make the game worse and it is the makers fault.

Last edited by powercon5 (May 28, 2016 05:15:48)

alexphan
Scratcher
1000+ posts

On page load

So you mean have code run while the page is loading?
How would that work? Scratch cannot function until the whole entire project is loaded. (correct me if I'm wrong)

Last edited by alexphan (May 27, 2016 22:10:06)

Skelepound
Scratcher
100+ posts

On page load

That's a bit confusing, so I'd say no support. If you're just wanting to make a block that does things only once, I'd say use the blocks below.
whenclickedifVariable=1thensetVariableto0Doyourcode
Just make sure to always set ‘Variable’ to 1 before sharing your project, and now you have code that executes right when you click the flag, but only once. (Unless you reload the page)
powercon5
Scratcher
1000+ posts

On page load

alexphan wrote:

So you mean have code run while the page is loading?
How would that work? Scratch cannot function until the whole entire project is loaded. (correct me if I'm wrong)
No it is code that only runs once the page has loaded after that it won't run again

Skelepound wrote:

That's a bit confusing, so I'd say no support. If you're just wanting to make a block that does things only once, I'd say use the blocks below.
whenclickedifVariable=1thensetVariableto0Doyourcode
Just make sure to always set ‘Variable’ to 1 before sharing your project, and now you have code that executes right when you click the flag, but only once. (Unless you reload the page)
I already put that however I am just saying for people un-sure and so that when you test your game and forget to reset it your game does not break.
f1lip
Scratcher
1000+ posts

On page load

As Skelepound said, this would be too confusing. No support.
powercon5
Scratcher
1000+ posts

On page load

f1lip wrote:

As Skelepound said, this would be too confusing. No support.
What is confusing?
alexphan
Scratcher
1000+ posts

On page load

powercon5 wrote:

alexphan wrote:

So you mean have code run while the page is loading?
How would that work? Scratch cannot function until the whole entire project is loaded. (correct me if I'm wrong)
No it is code that only runs once the page has loaded after that it won't run again
You can just do this:
whenclicked. . .stopthis script
powercon5
Scratcher
1000+ posts

On page load

alexphan wrote:

powercon5 wrote:

alexphan wrote:

So you mean have code run while the page is loading?
How would that work? Scratch cannot function until the whole entire project is loaded. (correct me if I'm wrong)
No it is code that only runs once the page has loaded after that it won't run again
You can just do this:
whenclicked. . .stopthis script
No, that will run after every green flag clicked.
powercon5
Scratcher
1000+ posts

On page load

Bump.
powercon5
Scratcher
1000+ posts

On page load

Bump
A-KouZ1
Scratcher
100+ posts

On page load

…(whatever somewhat i can try to understand)
You should put reset data scripts after when flag is clicked block, then run your scripts,
this helps?

Last edited by A-KouZ1 (May 30, 2016 09:54:08)

powercon5
Scratcher
1000+ posts

On page load

A-KouZ1 wrote:

…(whatever somewhat i can try to understand)
You should put reset data scripts after when flag is clicked block, then run your scripts,
this helps?
No I don't have a problem I even put that, maybey I should have used scratch blocks?

I am trying to say so it does to run when you press the green flag only when the project loads Because when you test a project you can forget to re-set it and your game can be broken.
A-KouZ1
Scratcher
100+ posts

On page load

powercon5 wrote:

No I don't have a problem I even put that, maybey I should have used scratch blocks?

I am trying to say so it does to run when you press the green flag only when the project loads Because when you test a project you can forget to re-set it and your game can be broken.

ofc you put scratch blocks,
resetting data something is like…
whenclickedcleargotox:defaultxlocationy:defaultylocationsetpositionto0setscoreto0deleteallofmydataforever. . .

I just couldnt understand what are you saying…
it does to run when you press the green flag only when the project loads Because when you test a project you can forget to re-set it and your game can be broken.
agh .-.,

I try to understand somewhat like you say
The project is runs fine when you play it after loading the project, but when play it again and you forget to reset the game, project plays unexpectedly
You want to say it right?
powercon5
Scratcher
1000+ posts

On page load

A-KouZ1 wrote:

powercon5 wrote:

No I don't have a problem I even put that, maybey I should have used scratch blocks?

I am trying to say so it does to run when you press the green flag only when the project loads Because when you test a project you can forget to re-set it and your game can be broken.

ofc you put scratch blocks,
resetting data something is like…
whenclickedcleargotox:defaultxlocationy:defaultylocationsetpositionto0setscoreto0deleteallofmydataforever. . .

I just couldnt understand what are you saying…
it does to run when you press the green flag only when the project loads Because when you test a project you can forget to re-set it and your game can be broken.
agh .-.,

I try to understand somewhat like you say
The project is runs fine when you play it after loading the project, but when play it again and you forget to reset the game, project plays unexpectedly
You want to say it right?
I want it so when you first load a project it will run that code however if you ever press the green flag again it will not run unless you re-load the page.
Sorry for hard to understand text I right most of it when I am very tired.
maxhup010
Scratcher
57 posts

On page load

there's an easy fix for this…
1. create a variable called plays.
2. if you wanted this script to run just once you would use this. But if you wanted something else to happen after they have clicked the button more than once you would just use an if else block and put the code that would run in there.

whenclickedifPlays= 0thenyourcodechangePlaysby1

When you saved the project and shared, Plays would HAVE to be set to 0 for this to work

Last edited by maxhup010 (May 30, 2016 10:47:40)

jokebookservice1
Scratcher
1000+ posts

On page load

I support, But there is a workaround that does not use any variables or anything:
whentimer>-1Always true
powercon5
Scratcher
1000+ posts

On page load

maxhup010 wrote:

there's an easy fix for this…
1. create a variable called plays.
2. if you wanted this script to run just once you would use this. But if you wanted something else to happen after they have clicked the button more than once you would just use an if else block and put the code that would run in there.

whenclickedifPlays= 0thenyourcodechangePlaysby1

When you saved the project and shared, Plays would HAVE to be set to 0 for this to work
I know about that I even said it.

jokebookservice1 wrote:

I support, But there is a workaround that does not use any variables or anything:
whentimer>-1Always true
That does not work.
jokebookservice1
Scratcher
1000+ posts

On page load

powercon5 wrote:

maxhup010 wrote:

there's an easy fix for this…
1. create a variable called plays.
2. if you wanted this script to run just once you would use this. But if you wanted something else to happen after they have clicked the button more than once you would just use an if else block and put the code that would run in there.

whenclickedifPlays= 0thenyourcodechangePlaysby1

When you saved the project and shared, Plays would HAVE to be set to 0 for this to work
I know about that I even said it.

jokebookservice1 wrote:

I support, But there is a workaround that does not use any variables or anything:
whentimer>-1Always true
That does not work.
Oh well, anyway, I still Support.
liam48D
Scratcher
1000+ posts

On page load

A-KouZ1 wrote:

I just couldnt understand what are you saying…
it does to run when you press the green flag only when the project loads Because when you test a project you can forget to re-set it and your game can be broken.
agh .-.,

I try to understand somewhat like you say
The project is runs fine when you play it after loading the project, but when play it again and you forget to reset the game, project plays unexpectedly
You want to say it right?
Yeah, I think that's what they're saying. The way somebody would probably make a project do something on the first green flag click is like so:

whenclickedifdidrun=nosetdid runtoyesdosomethingsetdid runtono click this after finished changing project!

The problem is that if they forget to clickon the “set did run to no” block, it'll look like the project has ran, even though it hasn't, when somebody else opens up the project.

You could solve this like so:

whenclicked this is the same as the previousifdidrun=nosetdid runtoyesdosomethingwhenpageloadedsetdid runtono

That will automatically set “did run” to no every time someone opens the project. You don't need to worry about clicking on the “set did run to no” block every time you use the project!

Though I wonder, would a built-in “flag clicked yet?” block be more useful..?

whenclickedifnotflagclickedyet?dosomething
jokebookservice1
Scratcher
1000+ posts

On page load

liam48D wrote:

A-KouZ1 wrote:

I just couldnt understand what are you saying…
it does to run when you press the green flag only when the project loads Because when you test a project you can forget to re-set it and your game can be broken.
agh .-.,

I try to understand somewhat like you say
The project is runs fine when you play it after loading the project, but when play it again and you forget to reset the game, project plays unexpectedly
You want to say it right?
Yeah, I think that's what they're saying. The way somebody would probably make a project do something on the first green flag click is like so:

whenclickedifdidrun=nosetdid runtoyesdosomethingsetdid runtono click this after finished changing project!

The problem is that if they forget to clickon the “set did run to no” block, it'll look like the project has ran, even though it hasn't, when somebody else opens up the project.

You could solve this like so:

whenclicked this is the same as the previousifdidrun=nosetdid runtoyesdosomethingwhenpageloadedsetdid runtono

That will automatically set “did run” to no every time someone opens the project. You don't need to worry about clicking on the “set did run to no” block every time you use the project!

Though I wonder, would a built-in “flag clicked yet?” block be more useful..?

whenclickedifnotflagclickedyet?dosomething
Isn't the flag to run the project a green flag too?

Powered by DjangoBB