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

Spawning custom FX?

April 29 (9 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I'm having some trouble with the new FX API functions trying to spawn custom FX. I've created a custom FX named "mist" and then set up a section of code like this:

var x = source.get('left');
var y = source.get('top');
var pageid = source.get('_pageid');
spawnFx(x, y, 'mist', pageid);
but it produces the default burn-fire effect instead. 

The definition for the mist FX is
{
	"maxParticles": 100,
	"emissionRate": 1,
	"size": 100,
	"sizeRandom": 50,
	"lifeSpan": 30,
	"lifeSpanRandom": 3,
	"speed": 3,
	"speedRandom": 1.5,
	"gravity": {"x":0.01, "y":0.1},
	"angle": 0,
	"angleRandom": 180,
	"duration": -1,
	"startColour": [255, 255, 255, 0.1],
	"startColourRandom": [0, 0, 0, 0],
	"endColour": [32, 0, 255, 0],
	"endColourRandom": [0, 0, 60, 0]
}

Any idea what I might be doing wrong here?
April 29 (9 years ago)
The Aaron
Pro
API Scripter
Does it work fine from the toolbar?
April 29 (9 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Yes, from the toolbar it works.
April 29 (9 years ago)
The Aaron
Pro
API Scripter
I'd probably start taking things away until it works, then see which thing it was.
April 29 (9 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
The FX defintion properties? I tried removing those one by one to try to rule out any bad values that work in the toolbar but not in the API. No results.
April 29 (9 years ago)
The Aaron
Pro
API Scripter
Weird....  I got nothing.  Any difference in Prod vs. Dev?
April 29 (9 years ago)

Edited April 29 (9 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Same result on development and production: It only produces the burn-fire effect if I try to spawn a custom FX.
April 29 (9 years ago)
Lithl
Pro
Sheet Author
API Scripter
Does your effect definition work with spawnFxWithDefinition? It could be that spawnFx is having an issue figuring out names.
April 29 (9 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
So far I've had a different issue with spawnFxWithDefinition. It works on development, but not on production, even though the devs recently announced that the feature is now on production.
April 29 (9 years ago)
Phil B.
Forum Champion
Sheet Author
Hey Stephen, I just took a look and it's happening with me as well. Sadly, the API stuff is not my forte, so there is not a whole lot of help I can give right now. I've logged this bug, and will bring it up to Riley on Monday.
April 29 (9 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Thanks, Phil. I'll just hold off for a bit on the FX features for my scripts then.
May 02 (9 years ago)

Edited May 02 (9 years ago)
Riley D.
Roll20 Team
Stephen -- When you use spawnFx, you must provide the ID of the effect, not the shortname. You can get the ID using something like:

findObjs({_type: "custfx", name: "mist"})[0].id

I think there is some code missing on the Prod server now that I think about it that needs to be present for spawnFXWithDefinition to work...the code to make it work is present in the API side but I think it might not have made it to the client side in the last merge. I'll get that fixed today.
May 02 (9 years ago)
Riley D.
Roll20 Team
I think the spawnFxByDefinition stuff should be fixed as well. Thanks!
May 02 (9 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Thanks, Riley. I'll give that a shot using the ID instead of a name.
May 02 (9 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
The custom FX stuff is working great now! Thanks!