{ "name": "Gold Totals", "type": "script", "author": "ueJGUfSYuRRL3Ypr", "img": "icons/commodities/currency/coins-plain-stack-gold-yellow.webp", "scope": "global", "command": "let tokens = []\nif (canvas.tokens.controlled.length > 0) {\n tokens = canvas.tokens.controlled\n}\nif (tokens.length > 0) {\n main(tokens)\n} else {\n ui.notifications.error('Please select or target a token')\n}\n\nasync function main (tokens) {\n const currencies = ['Copper', 'Silver', 'Gold', 'Platinum']\n let template = '
'\n const fmtOptions = {\n minimumIntegerDigits: 1,\n minimumFractionDigits: 2,\n maximumFractionDigits: 2\n }\n const fmt = Intl.NumberFormat('en-US', fmtOptions)\n for (const token of tokens) {\n const actor = token.actor\n let total = 0\n for (const item of actor.items.filter(i => currencies.indexOf(i.name) > -1)) {\n total += item.system.price * item.system.quantity\n }\n template += ``\n }\n template += ''\n Dialog.prompt({\n title: 'Currency Totals',\n content: template\n })\n}", "ownership": { "default": 0, "ueJGUfSYuRRL3Ypr": 3 }, "flags": { "advanced-macros": { "runAsGM": false, "runForSpecificUser": "" }, "exportSource": { "world": "swade-module-test", "system": "swade", "coreVersion": "10.291", "systemVersion": "2.2.5" }, "core": { "sourceId": "Macro.lOAxoK00x5QQFbTH" } }, "_stats": { "systemId": "swade", "systemVersion": "3.2.5", "coreVersion": "11.315", "createdTime": 1680966567327, "modifiedTime": 1702959790712, "lastModifiedBy": "sVoCvBU1knmXzoYe" }, "folder": null, "sort": 600000, "_id": "QMnx9cuyw81kRS2o", "_key": "!macros!QMnx9cuyw81kRS2o" }
ActorCurrency
${actor.name}${fmt.format(total)}