Browse Source

Functional: converts selected walls to red lines

tags/0.0.2
bertieb 3 years ago
parent
commit
9956cf8c8b
2 changed files with 14 additions and 8 deletions
  1. +2
    -2
      module.json
  2. +12
    -6
      scripts/wallconvert.js

+ 2
- 2
module.json View File

@@ -3,10 +3,10 @@
"title": "Walls-to-Drawing",
"description": "Convert selected walls to a Drawing to make walls visible to players",
"authors": [{ "name": "BertieB", "email": "foundry@bertieb.org", "url": "https://bertieb.org" }],
"version": "0.0.1",
"version": "0.0.2",
"minimumCoreVersion": "0.6.5",
"scripts": [ "scripts/wallconvert.js" ],
"url": "https://git.bertieb.org/bertieb/foundry-walls-to-drawing",
"manifest": "https://git.bertieb.org/bertieb/foundry-walls-to-drawing/raw/branch/master/module.json",
"download": "http://bertieb.org/walltest.zip"
"download": "https://git.bertieb.org/bertieb/foundry-walls-to-drawing/archive/0.0.2.zip"
}

+ 12
- 6
scripts/wallconvert.js View File

@@ -1,3 +1,9 @@
/** @constant {string} */
WALLCOLOUR = "#111111";

/** @constant {number} */
WALLWIDTH = "4";

/**
* Add 'Convert to walls' button in Walls Layer Tools
* */
@@ -6,10 +12,9 @@ Hooks.on('getSceneControlButtons', controls => {
let walls = controls.find(e => e.name === "walls");
walls.tools.push( {
"name": "convert-to-draw",
"icon": "fas fa-square",
"icon": "far fa-square",
"title": "Convert selected to Drawing",
"onclick": () => {
console.log("Converting selected to drawing");
"onClick": () => {
canvas.walls.controlled.forEach(function(wall) {
Drawing.create({
type: CONST.DRAWING_TYPES.POLYGON,
@@ -17,15 +22,16 @@ Hooks.on('getSceneControlButtons', controls => {
x: 0,
y: 0,
height: 100,
strokeWidth: 4,
strokeColor:"#FF0000",
strokeWidth: WALLWIDTH,
strokeColor: WALLCOLOUR,
points: [
[wall.coords[0], wall.coords[1]],
[wall.coords[2], wall.coords[3]]
]
});
});
console.log("Converted walls to Drawings");
ui.controls.controls.find(e => e.name === "walls").activeTool = "select";
ui.controls.render();
}
});
});

Loading…
Cancel
Save