/** @constant {string} */ WALLCOLOUR = "#111111"; /** @constant {number} */ WALLWIDTH = "4"; /** @constant {string} */ MODULENAME = "foundry-walls-to-drawing"; /** * Set up configuration options * */ Hooks.on("init", () => { game.settings.register(MODULENAME, "cvWallColour", { name: "Converted Wall Colour", default: WALLCOLOUR, type: String, scope: "client", config: true, hint: "Enter a hexadecimal colour, eg #FF0000 for red" }); game.settings.register(MODULENAME, "cvWallWidth", { name: "Converted Wall Width", default: WALLWIDTH, type: Number, scope: "client", config: true, hint: "Enter a decimal width" }); /** * Add 'Convert to walls' button in Walls Layer Tools * */ Hooks.on('getSceneControlButtons', controls => { cvWallColour = game.settings.get(MODULENAME, "cvWallColour"); cvWallWidth = game.settings.get(MODULENAME, "cvWallWidth"); let walls = controls.find(e => e.name === "walls"); walls.tools.push( { "name": "convert-to-draw", "icon": "far fa-square", "title": "Convert selected to Drawing", "onClick": () => { canvas.walls.controlled.forEach(function(wall) { Drawing.create({ type: CONST.DRAWING_TYPES.POLYGON, author: game.user._id, x: 0, y: 0, height: 100, strokeWidth: cvWallWidth, strokeColor: cvWallColour, points: [ [wall.coords[0], wall.coords[1]], [wall.coords[2], wall.coords[3]] ] }); }); ui.controls.controls.find(e => e.name === "walls").activeTool = "select"; ui.controls.render(); } }); });