키패드 0~9번 위치에
모두 각각 인터렉션이 소환되어 있고
각각의 인터렉션에 부여된 태그가
keypad0, keypad1, keypad2 ...
라고 할 것이고 모든 인터렉션에 공통적으로
keypad 태그가 부여되어 있다고 하겠습니다
그리고 #, enter 등 비밀번호 입력을
완료 하였을 때 누르는 버튼의 인터렉션에는
keypadEnter 태그가 부여되어 있습니다
철문의 좌표는 x y z 라고 표현하겠습니다
그리고 아래 8 명령어를 채팅창에 입력해주세요
/scoreboard objectives add input dummy
/scoreboard objectives add temporary dummy
/scoreboard objectives add touchCount dummy
/scoreboard objectives add finalResult dummy
/scoreboard objectives add num dummy
/scoreboard players set #10 num 10
/scoreboard players set #100 num 100
/scoreboard players set #1000 num 1000
반복 | 무조건적
execute as @e[tag=keypad0] on target run scoreboard players set @s input 0
연쇄 | 무조건적
execute as @e[tag=keypad1] on target run scoreboard players set @s input 1
연쇄 | 무조건적
execute as @e[tag=keypad2] on target run scoreboard players set @s input 2
연쇄 | 무조건적
execute as @e[tag=keypad3] on target run scoreboard players set @s input 3
연쇄 | 무조건적
execute as @e[tag=keypad4] on target run scoreboard players set @s input 4
연쇄 | 무조건적
execute as @e[tag=keypad5] on target run scoreboard players set @s input 5
연쇄 | 무조건적
execute as @e[tag=keypad6] on target run scoreboard players set @s input 6
연쇄 | 무조건적
execute as @e[tag=keypad0] on target run scoreboard players set @s input 7
연쇄 | 무조건적
execute as @e[tag=keypad8] on target run scoreboard players set @s input 8
연쇄 | 무조건적
execute as @e[tag=keypad9] on target run scoreboard players set @s input 9
연쇄 | 무조건적
execute as @a if score @s input = @s input run scoreboard players add @s touchCount 1
연쇄 | 무조건적
execute as @a store result score @s finalResult if score @s touchCount matches 1 run scoreboard players get @s input
연쇄 | 조건적
execute as @a if score @s touchCount matches 1 run scoreboard players operation @s final Result *= #1000 num
연쇄 | 무조건적
execute as @a store result score @s temporary if score @s touchCount matches 2 run scoreboard players get @s input
연쇄 | 조건적
execute as @a if score @s touchCount matches 2 run scoreboard players operation @s temporary *= #100 num
연쇄 | 조건적
execute as @a if score @s touchCount matches 2 run scoreboard players operation @s final Result += temporary
연쇄 | 무조건적
execute as @a store result score @s temporary if score @s touchCount matches 3 run scoreboard players get @s input
연쇄 | 조건적
execute as @a if score @s touchCount matches 3 run scoreboard players operation @s temporary *= #10 num
연쇄 | 조건적
execute as @a if score @s touchCount matches 3 run scoreboard players operation @s final Result += temporary
연쇄 | 무조건적
execute as @a if score @s touchCount matches 4 run scoreboard players operation @s finalResult += @s input
연쇄 | 무조건적
execute as @a if score @s touchCount matches 5.. run scoreboard players set @s finalResult -1
연쇄 | 무조건적
execute as @e[tag=keypadEnter] on target unless score @s finalResult matches 1010 run title @s actionbar {"text":"비밀번호가 일치하지 않습니다","color":"red"}
연쇄 | 무조건적
execute as @e[tag=keypadEnter] on target if score @s finalResult matches 1010 run setblock x y z iron_door[powered=true]
(문 방향은 facing 인자로 알아서 하시고
혹시 이게 안된다면 y좌표 (y-2) 좌표에다가
레드스톤 토치 설치되게 하는게..)
연쇄 | 무조건적
execute as @e[tag=keypadEnter] on target run scoreboard players reset @s touchCount
연쇄 | 무조건적
execute as @e[tag=keypadEnter] on target run scoreboard players reset @s finalResult
연쇄 | 무조건적
scoreboard players reset @a input
연쇄 | 무조건적
scoreboard players reset @a temporary
연쇄 | 무조건적
execute as @e[type=keypad] run data remove entity @s interaction
키패드를 누르면 소리가 난다던지의 커맨드는
알아서 할 수 있을거라 믿습니다