Scenes in conditional code

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

Scenes in conditional code

I’d use it for this type of project:

Music in games and other stuff to prevent some bugs

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

Less complicated code and easy to fix bugs

Here is an example design I’ve made:

Sorry for bad handwriting, it says “When (Scene=Scene1)”.

I’ve seen something similar in another programming language, it looks like this:

Nothing

6 Likes

Whoops I noticed a bug when making a topic in this category (I edited it)
It says: I’ve seen something similar in another programming languageS (wrong), it looks like this:

3 Likes

This is actually already possible if you add a ‘set variable’ block before changing the scene!

3 Likes

Yes but then when you change the scene, the game starts again and that set variable will be set again.

2 Likes

Yes, but does it really reset the variable?

I don’t have advanced mode, but even if I had advanced mode, I would use ‘invisible’ blocks.

My brother created a game with scenes, but the backdrops glitched…

2 Likes

I’m talking about using a constantly changing variable at times

2 Likes

use a second variable from preventing that

3 Likes

I never really liked too many variables, but ig so

1 Like

Variable are only reset to 0 when you exit or edit the project.

When working with clones, you’ll need to add a “check once if (self total clones) = (1)” in all when game starts rules to prevent a glitch where all clones look exactly the same / clones even more than its supposed to (which can cause lag spikes real quick).

4 Likes

also when a scene changes, which causes When Game Starts rule to get run

3 Likes

THT should rename that the “When Scene Starts” block, imo… When Game Starts is a bit misleading, since most people think it only runs once per game start (and going to a new scene doesn’t always mean a game is starting (unless each scene is a different game instead of different levels or areas).

5 Likes

Tell me if I’m wrong but code from other scenes doesn’t run when you aren’t in that scene I think? If that was the case though you probably wouldn’t have suggested this in the first place.

3 Likes

It would still be cool to see something like this so that that code runs for that scene only.

3 Likes

Wait oh yeah you’re right whoops

1 Like

Hey can you leaders delete this topic

1 Like

I think this is a cool suggestion! We can keep the topic (unless you really want to delete). It looks like there might be a few different ideas which might meet different use cases:

  • When scene starts
  • scene name (I remember @Awesome_E had suggested a scene name variable when we were working on changes to the scene block)
  • scene number

These were some early ideas I had that might still work for a “scene name” variable. That could be used in conditionals!

4 Likes

Also something I forgot to mention for the topic was maybe also having an object variable for scenes, but that works too!

3 Likes