When I am created rule

A feature I’d like to see in Hopscotch is:

A rule that is similar to when object is cloned but that also affects the original object.

I’d use it for this type of project:

Any project where I need the original object and a clone to do the same/similar things or where I intend to use scenes.

Here are some examples of Hopscotch code that could be improved if we had this:

Code which only the original object runs once at the beginning of the project in projects with scenes.

16 Likes

That would be surprisingly useful!

I remember so many times where I wish this was a thing.

7 Likes

Hmm I always thought of it as
“There should be when game starts and when scene starts” but this makes more sense

6 Likes

Good idea, since I use clones a lot this would be useful.

8 Likes

I don’t really get it, can you or somebody explain more??

5 Likes

In a project using scenes, each scene is essentially it’s own “project”, and they’re all mashed together into one, where custom rules and variables all carry over.
So if you have a “when game starts” in scene 2, it doesn’t execute as soon as the play button is pressed, it executes as soon as scene 1 switches to scene 2.

If you have a shape art in scene 1, say, and switch to a trail art in scene 2, the trail art will only draw once you’re in scene 2, instead of as soon as the game starts / play button is pressed. So instead of going into scene 2 and having the trail art already created (as it would be if everything in scene 2 started as soon as we press play instead of when it switches to scene 2), we see the trail art being created.

To prevent that from happening, the “when I am created” block would execute everything as soon as the object existed, basically doing the trail art setup and start as soon as the play button was pressed, instead of waiting til it was scene 2

The current when game starts shouldn’t necessarily be “fixed” cuz it’s still useful in something like a platformer or other game with multiple levels.
All of the graphics and setup , for every scene / level could be done immediately using the “when I am created” block, but then you’d use the “when game starts” to start that level. Cuz if you didn’t have that, all of the levels would play simultaneously and that wouldn’t really be fun


hope that kinda helped? Not my best explanation

8 Likes

A current fix for that (if you wanted to fix it) could be to quickly switch through all the scenes right at the beginning, then go back to scene 1?

3 Likes

Right but if you have like 50 scenes, that’d be kinda painful and really inconvenient-- a separate rule would probably be a lot more helpful, and there are still a lot of other uses for it

5 Likes

that makes sense, thanks

yeah this would be nice even though I’m not a subscriber

4 Likes

You’re right about that.

4 Likes

I was thinking it would also wait until the scene is showing, since it doesn;t really make sense for code to be running for objects which aren’t on the current screen. It would only happen the first time you enter the scene, though.


Scenes will eventually be for everyone, though.

4 Likes

That’s true, but in some cases, it’d be so much easier to have them running as soon as the play button is tapped, like when you’re setting up a level or a background thta may take a while to load.

Be cool if there was a parameter or something in the block where you could specify exactly when/how it’d run.

5 Likes

Interesting

Meh

That can be done by setting a variable to one when the background is drawn, and drawing the background when the variable = 0

1 Like

Yeah ik but it’d just be easier and more convenient if we had a block that worked like that

2 Likes

It can? I thought that only objects in the current scene can do any code, and anyway all trails are erased when the scene changes.

2 Likes

This is true

Ohhhh, I didn’t know that… that really stinks. Clones ig could do everything in 1 frame

Bump