# Start by assuming the lever wall is correct
scoreboard players set #ok leverwall 1

# Required ON levers
execute unless block -75 140 44 minecraft:lever[powered=true] run scoreboard players set #ok leverwall 0
execute unless block -75 140 47 minecraft:lever[powered=true] run scoreboard players set #ok leverwall 0
execute unless block -75 139 48 minecraft:lever[powered=true] run scoreboard players set #ok leverwall 0
execute unless block -75 138 47 minecraft:lever[powered=true] run scoreboard players set #ok leverwall 0
execute unless block -75 138 45 minecraft:lever[powered=true] run scoreboard players set #ok leverwall 0
execute unless block -75 140 46 minecraft:lever[powered=true] run scoreboard players set #ok leverwall 0
execute unless block -75 138 44 minecraft:lever[powered=true] run scoreboard players set #ok leverwall 0

# Everything else must be OFF

# Top row, y=140
execute unless block -75 140 45 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0
execute unless block -75 140 48 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0
execute unless block -75 140 49 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0

# Middle row, y=139
execute unless block -75 139 44 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0
execute unless block -75 139 45 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0
execute unless block -75 139 46 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0
execute unless block -75 139 47 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0
execute unless block -75 139 49 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0

# Bottom row, y=138
execute unless block -75 138 46 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0
execute unless block -75 138 48 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0
execute unless block -75 138 49 minecraft:lever[powered=false] run scoreboard players set #ok leverwall 0

# Output
execute if score #ok leverwall matches 1 unless block -73 144 45 minecraft:redstone_block run setblock -73 144 45 minecraft:redstone_block
execute unless score #ok leverwall matches 1 unless block -73 144 45 minecraft:air run setblock -73 144 45 minecraft:air