I want do a combination lock with buttons, which would work just like in video I've linked below, but before that I need to know if is there any easier and less spacious way to have the same results, for example by using command blocks. Also I need this mechanism for only 6 buttons instead of 9, like on the screenshot I've attached.
Commands is the better way to go if you're making a map. This will make your machine more efficient.
The way I'd do it is use a score for the correct number of buttons pressed so far. Then, when they press a button, based on the score, see which button they were supposed to push next, and if the actually pressed button matches, increase the score by 1, otherwise reset it to 0.
First setup the scoreboard objective:
scoreboard objectives add code dummy
For example, say your combination is Spruce, Birch, Acacia, Dark Oak, Crimson, Warped. The Spruce button would run the following commands:
execute if score @p code matches 0 run scoreboard players add @p code 1
execute unless score @p code matches 0 run scoreboard players set @p code 0
Rollback Post to RevisionRollBack
This forum has somewhat of a workaround for inline code formatting, but it still uses BBCode, which kinda sucks.
So if for example Spruce button activates command: execute if score @p code matches 0 run scoreboard players add @p code 1, than next, the Acacia button activates command: execute if score @p code matches 1 run scoreboard players add @p code 2 and so on, yes?
I want do a combination lock with buttons, which would work just like in video I've linked below, but before that I need to know if is there any easier and less spacious way to have the same results, for example by using command blocks.
Also I need this mechanism for only 6 buttons instead of 9, like on the screenshot I've attached.
I would be very grateful for any suggestions :3
Commands is the better way to go if you're making a map. This will make your machine more efficient.
The way I'd do it is use a score for the correct number of buttons pressed so far. Then, when they press a button, based on the score, see which button they were supposed to push next, and if the actually pressed button matches, increase the score by 1, otherwise reset it to 0.
First setup the scoreboard objective:
For example, say your combination is Spruce, Birch, Acacia, Dark Oak, Crimson, Warped. The Spruce button would run the following commands:
This forum has somewhat of a workaround for inline code formatting, but it still uses BBCode, which kinda sucks.
So if for example Spruce button activates command: execute if score @p code matches 0 run scoreboard players add @p code 1, than next, the Acacia button activates command: execute if score @p code matches 1 run scoreboard players add @p code 2 and so on, yes?
No, each subsequent button should still add 1. You only increase the score to check for, not the number to add.
This forum has somewhat of a workaround for inline code formatting, but it still uses BBCode, which kinda sucks.
Ok, but what if want to make a combination like: Spruce, Birch, Acacia, Spruce?
abstract it to spruce=1 birch=2 acacia=3 spruce=1
In that case, the Spruce button would run the following commands:
This forum has somewhat of a workaround for inline code formatting, but it still uses BBCode, which kinda sucks.