Comments (4)
my only concern is tthat the existing code doesnt allow overwriting once set. So that would need to be added in logic wise to the macro.
from tokenmagic.
Here's my working best re-iteration:
let path1 = "/Images/Tokens/Custom/Disguises/" //change this to where you want to put disguises/forms to change
// This macro contains a small tutorial : how to work with non-infinite loops and halfCosOscillation animType
// Click once to transform your token and again to revert to the original shape (thank to halfCosOscillation)
// There is 9 types of metamorphose
// 1 - Simple transition
// 2 - Dreamy
// 3 - Twist
// 4 - Water drop
// 5 - TV Noise
// 6 - Morphing
// 7 - Take off/Put on you disguise!
// 8 - Wind
// 9 - Hologram
// change the type here
let transitionType = 8;
// declare filter id (think to change the id for personal macros)
// each filterId should be unique to a player or gm to prevent collisions
// example : "brutusChthulhuPolymorph"
let polymorphFilterId = "myPolymorph";
// we put our code into an async function that will be called later
let polymorphFunc = async function () {
for (const token of canvas.tokens.controlled) {
let params;
// Is the filter already activated on the placeable ?
if (token.TMFXhasFilterId(polymorphFilterId)) {
// Yes. So we update the type in the general section and loops + active in the progress animated section, to activate the animation for just one loop.
// "type" to allow you to change the animation type
// "active" to say at Token Magic : "Hey filter! It's time to work again!"
// "loops" so that Token Magic can know how many loops it needs to schedule for the animation.
// Each animation loop decreases "loops" by one. When "loops" reach 0, "active" becomes "false" and the animation will be dormant again.
// Thank to the halfCosOscillation, a loop brings the value of the property from val1 to val2. A second loop is needed to bring val2 to val1. This is useful for monitoring progress with back and forth movements.
params =
[{
filterType: "polymorph",
filterId: polymorphFilterId,
type: transitionType,
animated:
{
progress:
{
active: true,
loops: 1
}
}
}];
await token.TMFXaddUpdateFilters(params);
let wait = async (ms) => new Promise((resolve)=> setTimeout(resolve, ms));
await wait(1900)
await TokenMagic.deleteFiltersOnSelected(polymorphFilterId)
} else {
let fp2 = new FilePicker({
type: "image",
current: path1,
displayMode: "tiles",
callback: path => {
// change the target image here
let targetImagePath = path;
// No. So we create the entirety of the filter
params =
[{
filterType: "polymorph",
filterId: polymorphFilterId,
type: transitionType,
padding: 70,
magnify: 1,
imagePath: targetImagePath,
animated:
{
progress:
{
active: true,
animType: "halfCosOscillation",
val1: 0,
val2: 100,
loops: 1,
loopDuration: 1000
}
}
}];
token.TMFXaddUpdateFilters(params);
},
})
fp2.browse();
// all functions that add, update or delete filters are asynchronous
// if you are in a loop AND/OR you chain these functions, it is MANDATORY to await them
// otherwise, data persistence may not works.
// this is the reason why we use an async function (we cant use await in a non-async function)
// avoid awaiting in a forEach loop, use "for" or "for/of" loop.
}
}
};
// polymorph async function call
polymorphFunc();
from tokenmagic.
Thanks for the file picking improvement.
@kelanel If you're Ok, I could add your macro to the TokenMagic compendium?
from tokenmagic.
Postponed.
from tokenmagic.
Related Issues (20)
- Applying effects to a specific PIXI.Sprite HOT 1
- BUG: Drop Shadow degrades quality of the tile. Blurs it. HOT 6
- [BUG] Effects not displaying correctly HOT 1
- Low performance mode w stretched static template textures HOT 2
- [Question] Add more default presets to Effects HOT 2
- [BUG] Zapshadow not working as effect(not compendium)
- [BUG] Unable to download module in v11 Stable HOT 11
- [BUG] Displacement Filters Not Working HOT 1
- Playing animations without GM.
- [BUG] Cannot set properties of undefined (setting 'renderable') HOT 1
- Build JS files into a bundle to reduce requests
- Include language to make macros toggleable or include examples of toggle FX. HOT 4
- [BUG] Texture Opacity on Templates not working correctly HOT 2
- Add explanation of `sticky` in readme (fixes rotation)
- [BUG] incompatibility with system customizer HOT 2
- [BUG] : In french, config screen displays damage types as [Object object]
- Feature: Better compatibility with Walled Templates module HOT 1
- [BUG] Incompatible with Foundry V12 HOT 20
- [BUG] v12 deprecation warnings
- Foundry v12 Template ui problem HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokenmagic.