{"id":20651858,"url":"https://github.com/jingshing/fvtt-transformitemtutorial","last_synced_at":"2026-01-31T13:46:21.975Z","repository":{"id":255468634,"uuid":"851636357","full_name":"JingShing/FVTT-TransformItemTutorial","owner":"JingShing","description":"a macro tutorial help making item transform effect.","archived":false,"fork":false,"pushed_at":"2024-09-04T13:12:19.000Z","size":6198,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-23T00:07:16.190Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JingShing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-03T13:05:57.000Z","updated_at":"2024-09-04T13:12:25.000Z","dependencies_parsed_at":"2024-09-05T15:33:38.984Z","dependency_job_id":"7b3baa80-7af2-4a21-9fff-8ee7b51578b0","html_url":"https://github.com/JingShing/FVTT-TransformItemTutorial","commit_stats":null,"previous_names":["jingshing/fvtt-transformitemtutorial"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JingShing/FVTT-TransformItemTutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingShing%2FFVTT-TransformItemTutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingShing%2FFVTT-TransformItemTutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingShing%2FFVTT-TransformItemTutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingShing%2FFVTT-TransformItemTutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JingShing","download_url":"https://codeload.github.com/JingShing/FVTT-TransformItemTutorial/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingShing%2FFVTT-TransformItemTutorial/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28944789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T13:02:32.153Z","status":"ssl_error","status_checked_at":"2026-01-31T13:00:07.528Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T17:30:04.113Z","updated_at":"2026-01-31T13:46:21.942Z","avatar_url":"https://github.com/JingShing.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"English | [繁體中文](README_TCH.md)\r\n\r\n# FoundryVTT Item Transform Macro Tutorial\r\n\r\n## Example\r\n\r\n### Scriptable Items\r\n![example](img/example.gif)\r\n### Scriptable Items with dialog\r\n![button_dialog](img/button_dialog.png)\r\n\r\n![dialog_select](img/dialog_select.png)\r\n### Dynamic Active Effects\r\n![example_dae](img/example_dae.gif)\r\n## Module-Optional\r\n\r\n* [Scriptable Items](https://foundryvtt.com/packages/scriptable-items)\r\n* [Dynamic Active Effects](https://foundryvtt.com/packages/dae)\r\n\r\n## Base Script\r\n\r\n\u003e If you don't want to use module to do it\r\n\r\n### add item to actor\r\n\r\n```js\r\n// get a actor called test\r\nlet test =game.actors.getName(\"test\");\r\n// get item id called XD3kQ0JxvPDamH2m\r\nlet testitem=game.items.get(\"XD3kQ0JxvPDamH2m\");\r\n// add item to actor\r\ntest.createEmbeddedDocuments(\"Item\", [testitem.toObject()])\r\n```\r\n\r\n### delete item from actor\r\n\r\n```js\r\n// get item in actor\r\nlet item;\r\n// using delete function to removed item from actor\r\nitem.delete();\r\n```\r\n\r\n### get item from compendium\r\n```js\r\n// id format: Compendium.dnd5e_classpack.itempack.Item.A8FA9E9D797EC9FB\r\n// removed Compendium\r\n// dnd5e_classpack.itempack is pack id\r\n// A8FA9E9D797EC9FB is item id\r\n\r\n// first get pack\r\nlet testPack = game.packs.get(\"dnd5e_classpack.itempack\");\r\n// then use id to find item\r\nlet testItem = await testPack.getDocument(\"A8FA9E9D797EC9FB\");\r\n```\r\n\r\n## With module-Scriptable Items\r\n### Reference\r\n[scriptable Items Instruction](https://github.com/FurtherV/scriptable-items)\r\n### How to setup\r\n\r\n* Create item\r\n* Click \"scriptable item\" button on top\r\n  * ![script_item](img/script_item.png)\r\n* It will open a edit page\r\n  * ![edit](img/edit.png)\r\n* add triggers with button\r\n  * ![button](img/button.png)\r\n* add script\r\n  * ![add_script](img/add_script.png)\r\n\r\n### Script\r\n\r\n```js\r\n// get actor\r\nlet cActor = actor;\r\n// item you wanna transform\r\nlet giveItem=game.items.get(\"B1QGodNijs2Ro5Ie\");\r\n// add item to actor\r\ncActor.createEmbeddedDocuments(\"Item\", [giveItem.toObject()])\r\n// delete chat room button message generated from this script\r\noptional.message.delete();\r\n// remove original item\r\nitem.delete();\r\n```\r\n\r\n## With module using dialog-Scriptable Items\r\nUsing \"Scriptable Items\" setup.\r\n\r\nChange the script;\r\n### Script\r\n\r\n```js\r\nnew Dialog({\r\n  // put menu title here\r\n  title: \"Transform select menu\",\r\n  // put instruction in here\r\n  content: \"This is transfrom instructions\",\r\n  // setting buttons also selection in below\r\n  buttons: {\r\n    button1: {\r\n      // this is button called \"A\"\r\n      label: \"A\",\r\n      callback: () =\u003e {\r\n      // put code give item, select item and delete message in here\r\n      // here is how button work so just put code in here area\r\n)},\r\n      // setting icon here\r\n      icon: `\u003ci class=\"fas fa-check\"\u003e\u003c/i\u003e`\r\n    },\r\n    button2: {\r\n      label: \"B\",\r\n      callback: () =\u003e {\r\n},\r\n      icon: `\u003ci class=\"fas fa-times\"\u003e\u003c/i\u003e`\r\n    }\r\n  }\r\n}).render(true);\r\n```\r\n\r\n## With module-Dynamic Active Effects\r\n### Reference\r\n[Dynamic Active Effects Instruction](https://gitlab.com/tposney/dae)\r\n### How to setup\r\n\r\n* Create item\r\n  * ![itemPage](img/ItemPage.png)\r\n* Click \"active effect\" button on top\r\n  * ![effect_page](img/activeEffect.png)\r\n* setting effect pause and transfer effect to actor, and your effect name\r\n  * Especially effect name as my script is based on effect name\r\n  * ![edit_effect](img/effect_set.png)\r\n* setting effect attribute to ```macro.itemMacro```\r\n  * ![edit_effect2](img/effect_set_2.png)\r\n* add script\r\n  * back to item page click \"DIME\" button on top\r\n  * ![DIME](img/DIME.png)\r\n\r\n### Script\r\n\r\n```js\r\n// when effect turn on it trigger\r\nif(args[0]==\"on\"){\r\n// get last args-\u003e last args contains multiple args we need\r\nlet cArgs = args[args.length-1];\r\n// get actor equipped or held item\r\nlet cActor = fromUuidSync(cArgs.actorUuid);\r\n// get item triggered effect\r\nlet cItem = cArgs.item;\r\n// get effect name\r\nlet cEfName = cArgs.efData.name;\r\n\r\nlet giveItemId = \"\";\r\n// if effect name called \"A\"\r\n// then item will be transform into itemA\r\nif(cEfName===\"A\"){\r\n// get itemA id and replace it\r\ngiveItemId=\"itemAid\";\r\n}\r\n\r\nif(cEfName===\"B\"){\r\ngiveItemId=\"itemBid\";\r\n}\r\n\r\n// if get right effect name then give player item and delete triggered item\r\nif(giveItemId!==\"\"){\r\n// get transfromed item\r\nlet giveItem=game.items.get(giveItemId);\r\n// add item to actor\r\ncActor.createEmbeddedDocuments(\"Item\", [giveItem.toObject()])\r\n// removed original item\r\ncItem .delete();\r\n}\r\n}\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjingshing%2Ffvtt-transformitemtutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjingshing%2Ffvtt-transformitemtutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjingshing%2Ffvtt-transformitemtutorial/lists"}