diff --git a/scripts/wallconvert.js b/scripts/wallconvert.js new file mode 100644 index 0000000..4555686 --- /dev/null +++ b/scripts/wallconvert.js @@ -0,0 +1,31 @@ +/** + * Add 'Convert to walls' button in Walls Layer Tools + * */ + +Hooks.on('getSceneControlButtons', controls => { + let walls = controls.find(e => e.name === "walls"); + walls.tools.push( { + "name": "convert-to-draw", + "icon": "fas fa-square", + "title": "Convert selected to Drawing", + "onclick": () => { + console.log("Converting selected to drawing"); + canvas.walls.controlled.forEach(function(wall) { + Drawing.create({ + type: CONST.DRAWING_TYPES.POLYGON, + author: game.user._id, + x: 0, + y: 0, + height: 100, + strokeWidth: 4, + strokeColor:"#FF0000", + points: [ + [wall.coords[0], wall.coords[1]], + [wall.coords[2], wall.coords[3]] + ] + }); + }); + console.log("Converted walls to Drawings"); + } + }); +});