Toggle between secret and normal door by ctrl+left click

This commit is contained in:
2020-12-07 23:06:53 +01:00
parent 598e323689
commit 408eee8bc0
4 changed files with 34 additions and 0 deletions

23
main.js
View File

@@ -168,6 +168,9 @@ function onDoorMouseDown(event) {
if ( game.paused && !game.user.isGM )
return false
if (toggleSecretDoorLeftClick.call(this, event))
return true
if (lockedDoorAlertLeftClick.call(this))
return true
@@ -179,12 +182,24 @@ function onDoorMouseDown(event) {
// Our custom handler for rightdown events on doors
function onDoorRightDown(event) {
if (synchronizedDoorsRightClick.call(this))
return true
return false
}
// Toggles between normal and secret doors
function toggleSecretDoorLeftClick(event) {
if (event.data.originalEvent.ctrlKey && game.user.isGM && game.settings.get(settingsKey, "toggleSecretDoors")) {
const types = CONST.WALL_DOOR_TYPES
const newtype = this.wall.data.door === types.DOOR ? types.SECRET : types.DOOR
this.wall.update({door: newtype})
return true
}
return false
}
// Creates a chat message stating that a player tried to open a locked door
function lockedDoorAlertLeftClick() {
const state = this.wall.data.ds
@@ -318,6 +333,14 @@ function registerSettings() {
default: true,
onChange: reloadGM,
})
game.settings.register(settingsKey, "toggleSecretDoors", {
name: "smart-doors.settings.toggleSecretDoors.name",
hint: "smart-doors.settings.toggleSecretDoors.hint",
scope: "world",
config: true,
type: Boolean,
default: true,
})
game.settings.register(settingsKey, "lockedDoorAlert", {
name: "smart-doors.settings.lockedDoorAlert.name",
hint: "smart-doors.settings.lockedDoorAlert.hint",