Morphan1_calico_DoorEvents:
type: world
debug: true
constants:
directions:
- 0,0,1
- 1,0,0
- 0,0,-1
- -1,0,0
- 0,0,-1
- -1,0,0
- 0,0,1
- 1,0,0
events:
on player right clicks block:
- if <context.location.material.name.contains[door]> {
- if <player.is_sneaking> && <context.item||i@air> != i@air {
- queue clear
}
- if <server.list_scripts> contains s@dRegions_CanUse_Block && !<proc[dRegions_CanUse_Block].context[<player>|<c.location>]||false> {
- queue clear
}
else {
- define loc <context.location.block>
- define data <def[loc].material.data>
- if %data% > 7 {
- define loc <context.location.block.sub[0,1,0]>
- define data <def[loc].material.data>
}
- - if <server.flag[doorcloser_door].as_list||null> contains %loc% {
- - determine cancelled
- }
- define direction <script.constant[directions].get[<def[data].add[1]>]>
- define top_data <def[loc].add[0,1,0].material.data>
- define other <def[loc].add[%direction%]>
- define other_top <def[other].add[0,1,0].material.data>
+ - if <server.flag[doorcloser_door].as_list||null> contains %loc% {
+ - flag server doorcloser_door:<-:%loc%
+ - flag server doorcloser_door:<-:%other%
+ }
- if <def[other].material.name.ends_with[door]> && <def[other].material.data> == %data% && %other_top% != %top_data% {
- switch %other%
- - narrate %other%
+ - if <def[loc].material.data> >= 4 {
+ - queue clear
+ }
- flag server doorcloser_door:->:%loc%
- flag server doorcloser_door:->:%other%
- wait 5s
+ - if <server.flag[doorcloser_door].as_list||null> !contains %loc% {
+ - queue clear
+ }
- switch %loc%
- switch %other%
- flag server doorcloser_door:<-:%loc%
- flag server doorcloser_door:<-:%other%
- queue clear
}
- define other <def[loc].sub[%direction%]>
- define other_top <def[other].add[0,1,0].material.data>
- if <def[other].material.name.ends_with[door]> && <def[other].material.data> == %data% && %other_top% != %top_data% {
- switch %other%
+ - if <def[loc].material.data> >= 4 {
+ - queue clear
+ }
- flag server doorcloser_door:->:%loc%
- flag server doorcloser_door:->:%other%
- wait 5s
+ - if <server.flag[doorcloser_door].as_list||null> !contains %loc% {
+ - queue clear
+ }
- switch %loc%
- switch %other%
- flag server doorcloser_door:<-:%loc%
- flag server doorcloser_door:<-:%other%
}
else {
- flag server doorcloser_door:->:%loc%
- wait 5s
- switch %loc%
- flag server doorcloser_door:<-:%loc%
}
}
}