A small add-on module for Foundry VTT which converts wall segments to drawings for quick maps
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

66 rindas
1.5 KiB

  1. /** @constant {string} */
  2. WALLCOLOUR = "#111111";
  3. /** @constant {number} */
  4. WALLWIDTH = "4";
  5. /** @constant {string} */
  6. MODULENAME = "foundry-walls-to-drawing";
  7. /**
  8. * Set up configuration options
  9. * */
  10. Hooks.on("init", () => {
  11. game.settings.register(MODULENAME, "cvWallColour", {
  12. name: "Converted Wall Colour",
  13. default: WALLCOLOUR,
  14. type: String,
  15. scope: "client",
  16. config: true,
  17. hint: "Enter a hexadecimal colour, eg #FF0000 for red"
  18. });
  19. game.settings.register(MODULENAME, "cvWallWidth", {
  20. name: "Converted Wall Width",
  21. default: WALLWIDTH,
  22. type: Number,
  23. scope: "client",
  24. config: true,
  25. hint: "Enter a decimal width"
  26. });
  27. /**
  28. * Add 'Convert to walls' button in Walls Layer Tools
  29. * */
  30. Hooks.on('getSceneControlButtons', controls => {
  31. cvWallColour = game.settings.get(MODULENAME, "cvWallColour");
  32. cvWallWidth = game.settings.get(MODULENAME, "cvWallWidth");
  33. let walls = controls.find(e => e.name === "walls");
  34. walls.tools.push( {
  35. "name": "convert-to-draw",
  36. "icon": "far fa-square",
  37. "title": "Convert selected to Drawing",
  38. "onClick": () => {
  39. canvas.walls.controlled.forEach(function(wall) {
  40. Drawing.create({
  41. type: CONST.DRAWING_TYPES.POLYGON,
  42. author: game.user._id,
  43. x: 0,
  44. y: 0,
  45. height: 100,
  46. strokeWidth: cvWallWidth,
  47. strokeColor: cvWallColour,
  48. points: [
  49. [wall.coords[0], wall.coords[1]],
  50. [wall.coords[2], wall.coords[3]]
  51. ]
  52. });
  53. });
  54. ui.controls.controls.find(e => e.name === "walls").activeTool = "select";
  55. ui.controls.render();
  56. }
  57. });
  58. });