-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
6 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
{"name":"Jobs","type":"script","author":"FIR7wPEGx1wVISuV","img":"icons/environment/people/commoner.webp","scope":"global","command":"/* - v1.1\nSource: brunocalado\nIcon: icons/environment/people/commoner.webp\n*/\n\n(async () => {\n const faction1 = await drawFromTable('Factions');\n const faction2 = await drawFromTable('Factions');\n const client = await drawFromTable('Client / Target');\n const target = await drawFromTable('Client / Target');\n const twist = await drawFromTable('Twist');\n const place = await drawFromTable('Job Location');\n const task = await drawFromTable('Work');\n const connection = await drawFromTable('Connection');\n\n let msg = `<h2>Job</h2>`;\n msg += `<ul><li>Faction 1: <b>${faction1}</b></li>`;\n msg += `<li>Faction 2: <b>${faction2}</b></li>`;\n msg += `<li>Client: <b>${client}</b></li>`;\n msg += `<li>Target: <b>${target}</b></li>`;\n msg += `<li>Twist: <b>${twist}</b></li>`;\n msg += `<li>Job Location: <b>${place}</b></li>`;\n msg += `<li>Job: <b>${task}</b></li>`;\n msg += `<li>Connection: <b>${connection}</b></li></ul>`;\n\n let message=msg;\n let msgId = randomID();\n\n let data = {\n name: `${task}`,\n content: msg\n }; \n \n message+=`<button style=\"background:#d10000;color:white\" id=\"createJob-`\n message+=msgId;\n message+=`\">Save As Journal Entry</button>`;\n\n let chatData = {\n content: message,\n whisper : ChatMessage.getWhisperRecipients(\"GM\")\n }; \n ChatMessage.create(chatData, {}); \n \n addEventListenerOnHtmlElement(\"#createJob-\" + msgId, 'click', (e) => {\n createJob(data); \n });\n})()\n\n/* Functions */\nasync function drawFromTable(tableName) {\n\n let roll_compendiums;\n let job_compendiums;\n roll_compendiums = game.packs.filter( p => p.documentName === 'RollTable');\n job_compendiums = await roll_compendiums.filter( p => p.metadata.label === 'Job Tables' )[0].getDocuments();\n const table = await job_compendiums.filter( p=> p.name === tableName )[0]; \n \n if (!table) {\n ui.notifications.warn(`Table ${tableName} not found.`, {});\n return;\n }\n const output = await table.roll();\n const result = output.results[0].text;\n return result; \n}\n\nfunction addEventListenerOnHtmlElement(element, event, func){ \n Hooks.on(\"renderChatMessage\", (chatItem, html, data) => {\n if( html[0].querySelector(element) !== null ) {\n html[0].querySelector(element).addEventListener(event, func);\n }\n });\n}\n\nasync function createJob(data) {\n\n let folder;\n if( game.folders.find( f => f.name === \"Job Ideas\") === undefined ) {\n folder = await Folder.create( {\n name: \"Job Ideas\",\n type: \"JournalEntry\"\n } );\n } else {\n folder = game.folders.find( f => f.name === \"Job Ideas\");\n }\n folder = folder;\n\n const instantAdventure = await JournalEntry.create(data);\n await instantAdventure.sheet.render(true); \n}","folder":null,"sort":0,"flags":{"core":{"sourceId":"Macro.GVICe576rSbJ1REF"}},"_id":"oN7DpBJRIfOACpzL","ownership":{"default":0,"FIR7wPEGx1wVISuV":3},"_stats":{"systemId":"scum-and-villainy","systemVersion":"2.0.0","coreVersion":"10.270","createdTime":null,"modifiedTime":1655580822493,"lastModifiedBy":"FIR7wPEGx1wVISuV"}} | ||
{"name":"Jobs","type":"script","author":"FIR7wPEGx1wVISuV","img":"icons/environment/people/commoner.webp","scope":"global","command":"/* - v1.1\nSource: brunocalado\nIcon: icons/environment/people/commoner.webp\n*/\n\n(async () => {\n const faction1 = await drawFromTable('Factions');\n const faction2 = await drawFromTable('Factions');\n const client = await drawFromTable('Client / Target');\n const target = await drawFromTable('Client / Target');\n const twist = await drawFromTable('Twist');\n const place = await drawFromTable('Job Location');\n const task = await drawFromTable('Work');\n const connection = await drawFromTable('Connection');\n\n let msg = `<h2>Job</h2>`;\n msg += `<ul><li>Faction 1: <b>${faction1}</b></li>`;\n msg += `<li>Faction 2: <b>${faction2}</b></li>`;\n msg += `<li>Client: <b>${client}</b></li>`;\n msg += `<li>Target: <b>${target}</b></li>`;\n msg += `<li>Twist: <b>${twist}</b></li>`;\n msg += `<li>Job Location: <b>${place}</b></li>`;\n msg += `<li>Job: <b>${task}</b></li>`;\n msg += `<li>Connection: <b>${connection}</b></li></ul>`;\n\n let message=msg;\n let msgId = randomID();\n\n let data = {\n name: `${task}`,\n content: msg\n }; \n \n message+=`<button style=\"background:#d10000;color:white\" id=\"createJob-`\n message+=msgId;\n message+=`\">Save As Journal Entry</button>`;\n\n let chatData = {\n content: message,\n whisper : ChatMessage.getWhisperRecipients(\"GM\")\n }; \n ChatMessage.create(chatData, {}); \n \n addEventListenerOnHtmlElement(\"#createJob-\" + msgId, 'click', (e) => {\n createJob(data); \n });\n})()\n\n/* Functions */\nasync function drawFromTable(tableName) {\n\n let roll_compendiums;\n let job_compendiums;\n roll_compendiums = game.packs.filter( p => p.documentName === 'RollTable');\n job_compendiums = await roll_compendiums.filter( p => p.metadata.label === 'Job Tables' )[0].getDocuments();\n const table = await job_compendiums.filter( p=> p.name === tableName )[0]; \n \n if (!table) {\n ui.notifications.warn(`Table ${tableName} not found.`, {});\n return;\n }\n const output = await table.roll();\n const result = output.results[0].text;\n return result; \n}\n\nfunction addEventListenerOnHtmlElement(element, event, func){ \n Hooks.on(\"renderChatMessage\", (chatItem, html, data) => {\n if( html[0].querySelector(element) !== null ) {\n html[0].querySelector(element).addEventListener(event, func);\n }\n });\n}\n\nasync function createJob(data) {\n\n let folder;\n if( game.folders.find( f => f.name === \"Job Ideas\") === undefined ) {\n folder = await Folder.create( {\n name: \"Job Ideas\",\n type: \"JournalEntry\"\n } );\n } else {\n folder = game.folders.find( f => f.name === \"Job Ideas\");\n }\n data.folder = folder;\n\n const instantAdventure = await JournalEntry.create(data);\n await instantAdventure.sheet.render(true); \n}","folder":null,"sort":0,"flags":{"core":{"sourceId":"Macro.GVICe576rSbJ1REF"}},"_id":"oN7DpBJRIfOACpzL","ownership":{"default":0,"FIR7wPEGx1wVISuV":3},"_stats":{"systemId":"scum-and-villainy","systemVersion":"2.0.0","coreVersion":"10.270","createdTime":null,"modifiedTime":1655580822493,"lastModifiedBy":"FIR7wPEGx1wVISuV"}} | ||
{"name":"Change XP Bars","type":"script","author":"DndvQQR4KOtSK1iV","img":"icons/sundries/misc/lock-open-yellow.webp","scope":"global","command":"const version = '1.1';\n\n/*\nhttps://raw.githubusercontent.com/brunocalado/mestre-digital/master/Foundry%20VTT/Macros/Forged%20in%20the%20Dark/BladesintheDark-XpBar.js\nicon: icons/sundries/misc/lock-open-yellow.webp\n*/\n\nlet tokenD;\n\nif (canvas.tokens.controlled[0] === undefined){\n ui.notifications.warn(\"You must select a token!\"); \n} else {\n tokenD = canvas.tokens.controlled[0].actor;\n main();\n}\n\nasync function main() {\n let attribute = [];\n if(tokenD.type === 'character'){\n attribute = Object.keys( game.system.model.Actor.character.attributes );\n attribute.push(\"class\");\n attribute.push(\"stress\");\n } else if(tokenD.type === 'ship'){\n attribute = [\"crew\"];\n }\n\n let attributeList = ``;\n attribute.map((t) => {\n attributeList += `<option value=\"${t}\">${t}</option>`;\n });\n \n new Dialog({\n title: `XP/Stress Bar - Manager - v${version}`,\n content: `\n <h2>Bar Size</h2>\n <p> \n <input type=\"number\" min=1 max=12 id=\"xpBarSize\" value=\"6\"/>\n </p><br>\n <h2>Choose Bar</h2>\n <p> \n <select id=\"attribute\" type=\"text\" style=\"width: 100px;\">\n ${attributeList}\n </select> \n </p> \n `,\n buttons: {\n roll: {\n label: \"Change\",\n callback: (html) => {\n changeActorSheetBar(html);\n }\n }, \n cancel: {\n label: \"Cancel\"\n }\n }\n }).render(true)\n}\n\nasync function changeActorSheetBar(html) {\n const xpBarSize = parseInt( html.find(\"#xpBarSize\")[0].value ); \n let attribute = html.find(\"#attribute\")[0].value;\n let updated; \n \n switch( attribute ){\n case 'class':\n updated = await Actor.updateDocuments([{_id: tokenD.id, \"system.experienceMax\": xpBarSize}]);\n break;\n case 'crew':\n updated = await Actor.updateDocuments([{_id: tokenD.id, \"system.crew_experienceMax\": xpBarSize}]);\n break;\n case 'stress':\n updated = await Actor.updateDocuments([{_id: tokenD.id, \"system.stress.max\": xpBarSize, \"system.stress.max_default\": xpBarSize}]);\n break;\n default:\n let key = \"system.attributes.\" + attribute + \".expMax\"; \n updated = await Actor.updateDocuments([{_id: tokenD.id, [key]: xpBarSize}]);\n }\n}","folder":null,"sort":0,"permission":{"default":0,"DndvQQR4KOtSK1iV":3},"flags":{"advanced-macros":{"runAsGM":false},"exportSource":{"world":"sav","system":"scum-and-villainy","coreVersion":"0.8.9","systemVersion":"1.9.4"},"core":{"sourceId":"Macro.R5S30v5UU19PIynf"}},"_id":"u1UhdaU5aGofIaAK"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters