Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

spawnFxBetweenPoints({ x: startX, y: startY }, { x: endX, y: endY }, fxType);

when i run this, it plays an effect, but not the custom effect i have entered. it just does a burn-fire at the caster's location. am i missing something? my use-case is that effect happen before roll20AM plays the sound for them. So, i'll just do it form the API with a setTimeout. on('chat:message', (msg) => {     if (msg.type !== 'api' || !msg.content.startsWith('!attack')) return;     const args = msg.content.split(' ').slice(1);     if (args.length < 2) {         const errorMessage = "Error: '!attack caster target' requires two arguments: caster and target token IDs.";         sendChat('', errorMessage);         return;     }     const [casterId, targetId] = args;     // Find the caster and target tokens     const caster = getObj('graphic', casterId);     const target = getObj('graphic', targetId);     if (!caster || !target) {         const errorMessage = `Error: Couldn't find tokens for caster ID: ${casterId} or target ID: ${targetId}.`;         sendChat('test', errorMessage);         return;     }     const trackName = "MESBeam";     const playTrackCommand = `!roll20AM --audio,play|${trackName}`;     sendChat("API", playTrackCommand);     setTimeout(() => {         const fxType = "MESBeam";         // coordinates for the start and end points         const startX = caster.get('left');         const startY = caster.get('top');         const endX = target.get('left');         const endY = target.get('top');         // Spawn the directional FX between the caster and target         spawnFxBetweenPoints({ x: startX, y: startY }, { x: endX, y: endY }, fxType);     }, 2000); });
ive tested that this is getting the coordinates. 4:31PM test: startX is 803.243771887833. startY is 519.115546178259. endX is 658.9549819043281. endY is 478.132739901028.
do i need to convert these coordinates to integers maybe?
Is this a Jumpgate game? The coordinate grid system is reversed in Jumpgate and doesn't work correctly with Mod scripts.
Jarren said: Is this a Jumpgate game? The coordinate grid system is reversed in Jumpgate and doesn't work correctly with Mod scripts. not a jumpgate game. Too many custom scripts at risk for me to do that right now
1732319279
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Jarren said: Is this a Jumpgate game? The coordinate grid system is reversed in Jumpgate and doesn't work correctly with Mod scripts. It's actually more complicated than that. The coordinate system has changed only for paths...
I don’t know if this helps, but here’s the custom MESBeam effect; { "angle": -1, "angleRandom": 0, "duration": 45, "emissionRate": 2500, "endColour": [175, 10, 10, 0], "endColourRandom": [0, 0, 0, 0], "lifeSpan": 11, "lifeSpanRandom": 0, "maxParticles": 42000, "size": 1, "sizeRandom": 0, "speed": 25, "speedRandom": 2, "startColour": [175, 50, 50, 1], "startColourRandom": [0, 0, 0, 0] } keithcurtis said: Jarren said: Is this a Jumpgate game? The coordinate grid system is reversed in Jumpgate and doesn't work correctly with Mod scripts. It's actually more complicated than that. The coordinate system has changed only for paths...
1732360453

Edited 1732360522
Ulti
Pro
Sheet Author
API Scripter
This is not how you can trigger custom effects: instead of a string, you need to provide the id of the custom effect. You need to do something like let effects = findObjs({_type: 'custfx', name:fxType}); //Maybe you should also check that effects is not empty, I leave it to you spawnFxBetweenPoints({ x: startX, y: startY }, { x: endX, y: endY }, effects[0].id); You can only use the effect name directly for predefined effects.
1732378560
The Aaron
Roll20 Production Team
API Scripter
Jarren said: Is this a Jumpgate game? The coordinate grid system is reversed in Jumpgate and doesn't work correctly with Mod scripts. While the underlying tech has a different coordinate system, the API shouldn't need to deal with it in most cases.  The only two I'm aware of right now are: Doors and Windows have reversed y coordinate (I've had some discussions about what it would take to fix that) lastmove on Graphics currently has reversed y, but that should be getting fixed soon. Path objects in Jumpgate have a different representation, but their points array is still using positive y toward the bottom of the page.  (The change of representation for the path object is what has broken most path related API scripts, but that should be cleared up shortly.)
Ulti said: This is not how you can trigger custom effects: instead of a string, you need to provide the id of the custom effect. You need to do something like let effects = findObjs({_type: 'custfx', name:fxType}); //Maybe you should also check that effects is not empty, I leave it to you spawnFxBetweenPoints({ x: startX, y: startY }, { x: endX, y: endY }, effects[0].id); You can only use the effect name directly for predefined effects. it didnt even occur to me that effects would have an ID to reference! I'll give this a shot right now
GM said: It worked beautifully. Someone pin this post somewhere! Ulti said: This is not how you can trigger custom effects: instead of a string, you need to provide the id of the custom effect. You need to do something like let effects = findObjs({_type: 'custfx', name:fxType}); //Maybe you should also check that effects is not empty, I leave it to you spawnFxBetweenPoints({ x: startX, y: startY }, { x: endX, y: endY }, effects[0].id); You can only use the effect name directly for predefined effects. it didnt even occur to me that effects would have an ID to reference! I'll give this a shot right now Ulti said: This is not how you can trigger custom effects: instead of a string, you need to provide the id of the custom effect. You need to do something like let effects = findObjs({_type: 'custfx', name:fxType}); //Maybe you should also check that effects is not empty, I leave it to you spawnFxBetweenPoints({ x: startX, y: startY }, { x: endX, y: endY }, effects[0].id); You can only use the effect name directly for predefined effects.