New here. need help

I need a mechanic where you can’t go to level 2 unless u pass level 1 here’s the game. https://arcade.makecode.com/S07805-95243-69832-23156

3 Likes

Welcome to Makecode Arcade

Once you complete level 1, set a value called level1completed to true. Then, when you are selecting level 2, do an if statement that checks whether or not level1completed = true. If it is, then you can do level 2, if not, then leave a message saying that you can’t or something.

2 Likes

thank you, but do you know how to use the settings extension for that? I want it to save if a restart

Just make it a setting instead of a variable

something like this:

3 Likes

thank you, but I’m not the smartest when it comes to coding, so. can you please make it a bit more understandable, i have trouble with settings blocks

1 Like

Hey @PizzaBoi , explaining @VoxelMaster64 setting blocks…

Creating the variable bool, it’s value is a boolean (true/false) which in this case he’s using the “setting with name “bool” exists” block.

What this block does is read the setting to see if it exists. If it doesn’t, it’s false, if it is, it’s true.

Setting blocks save data you give it so when you restart, it remembers what the value was.

When we press A, we set the variable bool value to “not bool.”

A not operator is a boolean operator that toggles the boolean value. So if the boolean is true, it’s false. And if the boolean is false, it’s true. In this case, we do it to show that the setting saves the previous value (true/false).

You might wonder why we do “if bool” instead of something like “if boolean == true/false.” The reason why is it’s a faster way to write true/false. And you can actually just put the variable like that for anything (sprites, bools, etc.)

So essentially, “is bool” = “is boolean equal to true?”.

If it’s true: We set a value to a setting (in this case, bool (or in you’re case when you use it, level)) to make sure it exists.

If it’s false: We’ll remove the setting to make sure it doesn’t exist.

Then we splash the boolean again to see if it exists.

The result is a toggle of true and false.

In you’re case, we’ll do it like this example:

1 Like

is this good?