Skip to content

Commit

Permalink
Updated module
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyVadala committed Dec 10, 2022
1 parent ec3855e commit 52b2f6b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 0 additions & 2 deletions misc/rebind_token_actors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

// Any Token with an altered name and an img path attached
// will look up the default actor name via provided URL.
// Very useful when using eg. Plutonium in combination with
// 5e.tools for importing creatures or other actors.
let tname, results, str, arr;

const dir = new ActorDirectory();
Expand Down
1 change: 1 addition & 0 deletions packs/macros-misc.db
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@
{"name":"Show Modules","permission":{"default":0,"y5gmtwxmW3A5ZuOP":3},"type":"script","flags":{},"scope":"global","command":"/**\n * Show Modules - Shows currently installed modules in foundry. Added on behalf of @vance\n */\nlet mods = '';\ngame.modules.forEach(m => {\n let a = m.active ? 'Enabled' : 'Disabled';\n mods = mods.concat(`${m.id}: ${a}\\n`);\n});\n\nlet d = new Dialog({\n title: `Enabled Mods`,\n content: `<textarea style=\"height: 500px;\" type=\"text\" id=\"modslist\" name=\"modslist\">${mods}</textarea>`,\n buttons: {\n copy: {\n label: `Copy to clipboard`,\n callback: () => {\n $(\"#modslist\").select();\n document.execCommand('copy');\n }\n },\n close: {\n icon: \"<i class='fas fa-tick'></i>\",\n label: `Close`\n },\n },\n default: \"close\",\n close: () => {}\n});\n\nd.render(true);","author":"y5gmtwxmW3A5ZuOP","img":"icons/svg/dice-target.svg","actorIds":[],"_id":"u71xIHwO8uVaLS8o"}
{"_id":"wosXzUFEMQLD84so","name":"Ambient Light Quick Edit","permission":{"default":0,"y5gmtwxmW3A5ZuOP":3},"type":"script","flags":{},"scope":"global","command":"let macroName = \"AmbientLight QuickEditor\"\nlet macroEndLog = \"---------------------------------------------\"\n\nlet i=0;\nlet lights = canvas.lighting.objects.children;\nlet lightSelected = lights[0];\nlet selectOptions = \"\";\nlet lightSelectedAngle = 0;\nlet lightSelectedBright = 0;\nlet lightSelectedDim = 0;\nlet lightSelectedRotation = 0;\nlet lightSelectedTintAlpha = 1;\nlet lightSelectedTintColor = \"\";\n\nconsole.log(\"---------------------------------------------\");\nconsole.log(`${macroName} by PaperPunk`);\nconsole.log(\"---------------------------------------------\");\nconsole.log(`${macroName} | Start`);\n\nconst drawingDetails = {\n author: game.user._id,\n fillAlpha: 0,\n fillColor: \"#808080\",\n fillType: 1,\n fontFamily: \"FontAwesome\",\n fontSize: 24,\n height: 48,\n hidden: false,\n locked: false,\n rotation: 0,\n strokeAlpha: 1,\n strokeColor: \"#000000\",\n strokeWidth: 2,\n text: i,\n textAlpha: 1,\n textColor: \"#ffffff\",\n type: \"r\",\n width: 48,\n //x: 250,\n x: lightSelected.x-24,\n //y: 250\n y: lightSelected.y+25\n};\n\n//let d = Drawing.create(drawingDetails);\n//d.update({\"x\": lights[i].x-24, \"y\": lights[i].y+25, \"text\": i});\n\nfor (i= 0; i< lights.length; i++) {\n selectOptions += `<option value=\"${i}\">AmbientLight ${i}</option>`;\n}\n\nconst htmlLightSelection = `\n <form>\n <h2>Select your light.</h2>\n <div class=\"form-group\">\n <label>Light:</label>\n <select id=\"light-selector\" name=\"light-selector\">\n ${selectOptions}\n </select>\n </div>\n </form>\n `;\n\nlet dialogSelector = new Dialog({\n title: `${macroName}`,\n content: htmlLightSelection,\n buttons: {\n confirm: {\n icon: \"<i class='fas fa-tick'></i>\",\n label: `Confirm`,\n callback: htmlLightSelection => { \n lightSelected = (htmlLightSelection.find('[name=\"light-selector\"]')[0].value)\n lightSelectedAngle = lights[lightSelected].data.angle;\n lightSelectedBright = lights[lightSelected].data.bright;\n lightSelectedDim = lights[lightSelected].data.dim;\n lightSelectedRotation = lights[lightSelected].data.rotation;\n lightSelectedTintAlpha = lights[lightSelected].data.tintAlpha;\n lightSelectedTintColor = lights[lightSelected].data.tintColor;\n //console.log(`${macroName} | lightSelected = ${lightSelected}`);\n //console.log(`${macroName} | lightSelectedBright = ${lightSelectedBright}`);\n dialogEditor.render(true);\n }\n },\n cancel: {\n icon: \"<i class='fas fa-times'></i>\",\n label: `Cancel`,\n callback: () => {\n console.log(`${macroName} | Goodbye`);\n console.log(macroEndLog);\n }\n },\n },\n default: \"cancel\",\n //close: () => console.log(\"AmbientLight QuickEditor | Dialog Window Closed\")\n});\n\nlet dialogEditor = new Dialog({\n title: `${macroName}`,\n content: `<h2>Edit your light.</h2>\n <p>Emission Angle: ${lightSelectedAngle}</p>\n <p>Bright light distance: ${lightSelectedBright}</p>\n <p>Dim light distance: ${lightSelectedDim}</p>\n <p>Rotation CW from down: ${lightSelectedRotation}</p>\n <p>Tint Alpha: ${lightSelectedAngle}</p>\n <p>Tint Color HexCode: ${lightSelectedAngle}</p>`,\n buttons: {\n rot5cw: {\n icon: \"<i class='fas fa-redo'></i>\",\n label: `Rotate 5* CW`,\n callback: () => { \n let rot = lights[lightSelected].data.rotation;\n lights[lightSelected].update({\"rotation\":rot+5});\n dialogEditor.render(true);\n }\n },\n rot15cw: {\n icon: \"<i class='fas fa-redo'></i>\",\n label: `Rotate 15* CW`,\n callback: () => { \n let rot = lights[lightSelected].data.rotation;\n lights[lightSelected].update({\"rotation\":rot+15});\n dialogEditor.render(true);\n }\n },\n rot45cw: {\n icon: \"<i class='fas fa-redo'></i>\",\n label: `Rotate 45* CW`,\n callback: () => { \n let rot = lights[lightSelected].data.rotation;\n lights[lightSelected].update({\"rotation\":rot+45});\n dialogEditor.render(true);\n }\n },\n rot5ccw: {\n icon: \"<i class='fas fa-undo'></i>\",\n label: `Rotate 5* CCW`,\n callback: () => { \n let rot = lights[lightSelected].data.rotation;\n lights[lightSelected].update({\"rotation\":rot-5});\n dialogEditor.render(true);\n }\n },\n rot15ccw: {\n icon: \"<i class='fas fa-undo'></i>\",\n label: `Rotate 15* CCW`,\n callback: () => { \n let rot = lights[lightSelected].data.rotation;\n lights[lightSelected].update({\"rotation\":rot-15});\n dialogEditor.render(true);\n }\n },\n rot45ccw: {\n icon: \"<i class='fas fa-undo'></i>\",\n label: `Rotate 45* CCW`,\n callback: () => { \n let rot = lights[lightSelected].data.rotation;\n lights[lightSelected].update({\"rotation\":rot-45});\n dialogEditor.render(true);\n }\n },\n brightup: {\n icon: \"<i class='fas fa-circle'></i>\",\n label: `Increase Bright by 5`,\n callback: () => { \n let bright = lights[lightSelected].data.bright;\n lights[lightSelected].update({\"bright\":bright+5});\n dialogEditor.render(true);\n }\n },\n brightdown: {\n icon: \"<i class='fas fa-circle'></i>\",\n label: `Decrease Bright by 5`,\n callback: () => { \n let bright = lights[lightSelected].data.bright;\n lights[lightSelected].update({\"bright\":bright-5});\n dialogEditor.render(true);\n }\n },\n brightoff: {\n icon: \"<i class='fas fa-circle'></i>\",\n label: `Remove Bright Light`,\n callback: () => { \n lights[lightSelected].update({\"bright\":0});\n dialogEditor.render(true);\n }\n },\n dimup: {\n icon: \"<i class='fas fa-dot-circle'></i>\",\n label: `Increase Dim by 5`,\n callback: () => { \n let dim = lights[lightSelected].data.dim;\n lights[lightSelected].update({\"dim\":dim+5});\n dialogEditor.render(true);\n }\n },\n dimdown: {\n icon: \"<i class='fas fa-dot-circle'></i>\",\n label: `Decrease Dim by 5`,\n callback: () => { \n let dim = lights[lightSelected].data.dim;\n lights[lightSelected].update({\"dim\":dim-5});\n dialogEditor.render(true);\n }\n },\n dimoff: {\n icon: \"<i class='fas fa-dot-circle'></i>\",\n label: `Remove Dim Light`,\n callback: () => { \n lights[lightSelected].update({\"dim\":0});\n dialogEditor.render(true);\n }\n },\n emit15: {\n icon: \"<i class='fas fa-rss'></i>\",\n label: `Emission Angle 15*`,\n callback: () => { \n lights[lightSelected].update({\"angle\":15});\n dialogEditor.render(true);\n }\n },\n emit45: {\n icon: \"<i class='fas fa-rss'></i>\",\n label: `Emission Angle 45*`,\n callback: () => { \n lights[lightSelected].update({\"angle\":45});\n dialogEditor.render(true);\n }\n },\n emit90: {\n icon: \"<i class='fas fa-rss'></i>\",\n label: `Emission Angle 90*`,\n callback: () => { \n lights[lightSelected].update({\"angle\":90});\n dialogEditor.render(true);\n }\n },\n emit180: {\n icon: \"<i class='fas fa-rss'></i>\",\n label: `Emission Angle 180*`,\n callback: () => { \n lights[lightSelected].update({\"angle\":180});\n dialogEditor.render(true);\n }\n },\n emit270: {\n icon: \"<i class='fas fa-rss'></i>\",\n label: `Emission Angle 270*`,\n callback: () => { \n lights[lightSelected].update({\"angle\":270});\n dialogEditor.render(true);\n }\n },\n emit360: {\n icon: \"<i class='fas fa-rss'></i>\",\n label: `Emission Angle 360*`,\n callback: () => { \n lights[lightSelected].update({\"angle\":360});\n dialogEditor.render(true);\n }\n },\n back: {\n icon: \"<i class='fas fa-reply'></i>\",\n label: `Back`,\n callback: () => dialogSelector.render(true)\n },\n close: {\n icon: \"<i class='fas fa-tick'></i>\",\n label: `Close`\n },\n },\n default: \"close\",\n close: () => {\n console.log(`${macroName} | Goodbye`);\n console.log(macroEndLog);\n }\n});\n\ndialogSelector.render(true);\n","author":"y5gmtwxmW3A5ZuOP","img":"icons/svg/dice-target.svg","actorIds":[]}
{"_id":"zsAzgwdGPAeArcIJ","name":"Lock All Doors","type":"script","author":"y5gmtwxmW3A5ZuOP","img":"icons/svg/dice-target.svg","scope":"global","command":"/**\n * Locks all closed doors on the canvas\n * Author: orcnog\n */\n \nawait canvas.walls.updateAll(w => ({ds: w.data.ds === CONST.WALL_DOOR_STATES.CLOSED ? CONST.WALL_DOOR_STATES.LOCKED : CONST.WALL_DOOR_STATES.CLOSED}), w => w.data.door === CONST.WALL_DOOR_TYPES.DOOR && (w.data.ds === CONST.WALL_DOOR_STATES.LOCKED || w.data.ds === CONST.WALL_DOOR_STATES.CLOSED));","folder":null,"sort":0,"permission":{"default":0,"y5gmtwxmW3A5ZuOP":3},"flags":{"core":{"sourceId":"Macro.sSGS2FhGOqiTIpRV"}}}
{"name":"Rebind Token Actors","type":"script","author":"y5gmtwxmW3A5ZuOP","img":"icons/svg/dice-target.svg","scope":"global","command":"// Rebinds the actor for all selected tokens.\n// Requirements: \n// - the actor must be present in the \"Actor Directory\"\n// - actor name can't contain either '/' or '.'\n\n// Any Token with an altered name and an img path attached \n// will look up the default actor name via provided URL.\n\nconst dir = new ActorDirectory();\n\nfor (const token of canvas.tokens.controlled) {\n tname = token.name;\n results = dir.documents.filter(obj => {if(obj.data.name === tname){return obj;}})\n if(results.length === 0){\n if(token.data.img){\n// Possible optimization: regEx look-up for any word character pre '.' and post '/'\n str = token.data.img;\n arr = str.split('/');\n tname = arr[arr.length-1].split('.')[0];\n results = dir.documents.filter(obj => {if(obj.data.name === tname){return obj;}})\n }\n }\n if(results.length > 0){\n await token.update({'actorId':results[0].data._id});\n }\n}","folder":null,"sort":0,"flags":{"core":{"sourceId":"Macro.T6rBYAF9cEQs1Tvj"}},"_id":"ie5zQi7onuxJezxN","ownership":{"default":0,"y5gmtwxmW3A5ZuOP":3},"_stats":{"systemId":"dnd5e","systemVersion":"2.0.3","coreVersion":"10.291","createdTime":null,"modifiedTime":1670654636695,"lastModifiedBy":"QMyNqXGlX06pnWfY"}}

0 comments on commit 52b2f6b

Please sign in to comment.