From 7c3c7c1639af99ce8194650d87ef1ad2645beab5 Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Sun, 26 Apr 2026 15:52:02 -0500 Subject: [PATCH] add scene control macros --- src/module.json | 2 +- src/module/mb-assets.js | 1 - ...Initialize_for_Reset_IycPnAcIgoRld15f.json | 28 +++++++++++++++++++ .../Scene_Control_oqN7Apl0opwjrNrU.json | 22 +++++++++++++++ .../Scene_Reset_Q7x20iNpmP1r4m6U.json | 28 +++++++++++++++++++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 src/packsrc/asset-macros/Initialize_for_Reset_IycPnAcIgoRld15f.json create mode 100644 src/packsrc/asset-macros/Scene_Control_oqN7Apl0opwjrNrU.json create mode 100644 src/packsrc/asset-macros/Scene_Reset_Q7x20iNpmP1r4m6U.json diff --git a/src/module.json b/src/module.json index a6ba869..e7053a2 100644 --- a/src/module.json +++ b/src/module.json @@ -1,7 +1,7 @@ { "id": "mb-assets", "title": "MB assets", - "version": "2.1.0", + "version": "2.3.0", "compatibility": { "minimum": "13", "verified": "13" diff --git a/src/module/mb-assets.js b/src/module/mb-assets.js index 42f8fe3..387c9cb 100644 --- a/src/module/mb-assets.js +++ b/src/module/mb-assets.js @@ -23,7 +23,6 @@ function _actorDropper(match, options) { if (!game.user.isGM) { const span = document.createElement("span"); span.innerHTML = ""; - anchor.innerHTML = ` ${qty} × ${label}`; return span; } const anchor = document.createElement("a"); diff --git a/src/packsrc/asset-macros/Initialize_for_Reset_IycPnAcIgoRld15f.json b/src/packsrc/asset-macros/Initialize_for_Reset_IycPnAcIgoRld15f.json new file mode 100644 index 0000000..9e46cfc --- /dev/null +++ b/src/packsrc/asset-macros/Initialize_for_Reset_IycPnAcIgoRld15f.json @@ -0,0 +1,28 @@ +{ + "folder": "oqN7Apl0opwjrNrU", + "name": "Initialize for Reset", + "type": "script", + "_id": "IycPnAcIgoRld15f", + "author": "sVoCvBU1knmXzoYe", + "img": "icons/svg/dice-target.svg", + "scope": "global", + "command": "const scene = canvas.scene;\nconst sceneId = scene.id;\nconst positionPlaceables = Tagger.getByTag(\"Reset_Position\", {sceneId});\nfor (const placeable of positionPlaceables) {\n if ([\"Token\", \"Drawing\", \"AmbientLight\", \"Tile\"].includes(placeable.documentName)) {\n const position = {\n x: placeable.x,\n y: placeable.y,\n elevation: placeable.elevation,\n rotation: placeable.rotation,\n }\n await placeable.setFlag(\"mb-assets\", \"reset.position\", position)\n }\n}", + "sort": 0, + "ownership": { + "default": 0, + "sVoCvBU1knmXzoYe": 3 + }, + "flags": {}, + "_stats": { + "compendiumSource": null, + "duplicateSource": null, + "exportSource": null, + "coreVersion": "13.351", + "systemId": "swade", + "systemVersion": "5.2.6", + "createdTime": 1777231934664, + "modifiedTime": 1777236225281, + "lastModifiedBy": "sVoCvBU1knmXzoYe" + }, + "_key": "!macros!IycPnAcIgoRld15f" +} diff --git a/src/packsrc/asset-macros/Scene_Control_oqN7Apl0opwjrNrU.json b/src/packsrc/asset-macros/Scene_Control_oqN7Apl0opwjrNrU.json new file mode 100644 index 0000000..8f771b8 --- /dev/null +++ b/src/packsrc/asset-macros/Scene_Control_oqN7Apl0opwjrNrU.json @@ -0,0 +1,22 @@ +{ + "type": "Macro", + "folder": "antf8BjHVvX5cTS7", + "name": "Scene Control", + "color": null, + "sorting": "a", + "_id": "oqN7Apl0opwjrNrU", + "description": "", + "sort": 0, + "flags": {}, + "_stats": { + "compendiumSource": null, + "duplicateSource": null, + "exportSource": null, + "coreVersion": "13.351", + "systemId": "swade", + "systemVersion": "5.2.6", + "lastModifiedBy": "sVoCvBU1knmXzoYe", + "modifiedTime": 1777235082762 + }, + "_key": "!folders!oqN7Apl0opwjrNrU" +} diff --git a/src/packsrc/asset-macros/Scene_Reset_Q7x20iNpmP1r4m6U.json b/src/packsrc/asset-macros/Scene_Reset_Q7x20iNpmP1r4m6U.json new file mode 100644 index 0000000..eba0def --- /dev/null +++ b/src/packsrc/asset-macros/Scene_Reset_Q7x20iNpmP1r4m6U.json @@ -0,0 +1,28 @@ +{ + "folder": "oqN7Apl0opwjrNrU", + "name": "Scene Reset", + "type": "script", + "_id": "Q7x20iNpmP1r4m6U", + "author": "sVoCvBU1knmXzoYe", + "img": "icons/svg/hazard.svg", + "scope": "global", + "command": "const scene = canvas.scene\nconst sceneId = scene.id;\nconst docUpdates = {\n Wall: [],\n Tile: [],\n Drawing: [],\n Token: [],\n AmbientLight: [],\n};\nconst position = Tagger.getByTag(\"Reset_Position\", {sceneId});\nconst showHide = {\n 0: Tagger.getByTag(\"Reset_Show\", {sceneId}),\n 1: Tagger.getByTag(\"Reset_Hide\", {sceneId}),\n};\nconst doors = {\n [foundry.CONST.WALL_DOOR_STATES.CLOSED]: Tagger.getByTag(\"Reset_Closed\", { sceneId } ),\n [foundry.CONST.WALL_DOOR_STATES.LOCKED]: Tagger.getByTag(\"Reset_Locked\", { sceneId } ),\n [foundry.CONST.WALL_DOOR_STATES.OPEN]: Tagger.getByTag(\"Reset_Open\", { sceneId } ),\n}\nfor (const obj of position) {\n if ([\"Token\", \"Drawing\", \"AmbientLight\", \"Tile\"].includes(obj.documentName)) {\n update = obj.getFlag(\"mb-assets\", \"reset.position\");\n if (update) {\n docUpdates[obj.documentName].push({\n _id: obj.id,\n ...update\n })\n }\n }\n}\nfor (const hiddenI in showHide) {\n const hidden = Boolean(Number(hiddenI))\n for (const obj of showHide[hiddenI]) {\n if (![\"Tile\", \"Drawing\", \"AmbientLight\", \"Token\"].includes(obj.documentName)) { continue; }\n console.log(\"hidden pre\", obj.hidden, hiddenI, hidden, obj)\n if (obj.hidden != hidden) {\n console.log(\"hidden\", obj.hidden, hidden, obj)\n docUpdates[obj.documentName].push({_id: obj.id, hidden: hidden})\n }\n }\n}\nfor (const doorState in doors) {\n for (const door of doors[doorState]) {\n if (door.documentName != \"Wall\") { continue; }\n if (door.ds != doorState) {\n docUpdates[\"Wall\"].push({_id: door.id, ds: doorState})\n }\n }\n}\nconsole.log(\"docUpdates\", docUpdates);\nfor (docType in docUpdates) {\n if (docUpdates[docType].length > 0) {\n scene.updateEmbeddedDocuments(docType, docUpdates[docType]);\n }\n}", + "sort": 0, + "ownership": { + "default": 0, + "sVoCvBU1knmXzoYe": 3 + }, + "flags": {}, + "_stats": { + "compendiumSource": null, + "duplicateSource": null, + "exportSource": null, + "coreVersion": "13.351", + "systemId": "swade", + "systemVersion": "5.2.6", + "createdTime": 1777234492333, + "modifiedTime": 1777236208698, + "lastModifiedBy": "sVoCvBU1knmXzoYe" + }, + "_key": "!macros!Q7x20iNpmP1r4m6U" +}