Extending ActiveEffectConfig (i.e. custom ActiveEffects sheet based on Svelte)
I want to create a custom ActiveEffects sheet. Advice from Foundry is:
However, I'm not sure how that ties into the examples for creating svelte-based sheets from esm?
12 Replies
Here's what I have so far:
There are two things in play here. The Foundry API side of things in relation to system setup.
Then on the TRL / Svelte side if you are dealing with documents use
TJSDocument
or TJSDocumentCollection
.And then I tried to assign it via:
But I'm still getting the default sheet
That's the Foundry API side of things. You'll have to ask help from other system devs here for any advice on that matter.
I can possibly help you on the TRL / Svelte side after you work out the Foundry stuff.
Looks like I got the Foundry side working with this:
I'm now getting errors in my attempted sheet:
Maybe... Just maybe... "Do weird shit / win weird prizes?"
Are you just copy / pasting random code from places together? It looks like you took some code from some example based on core AppV1 / FormApplication and dropped it into SvelteApplication and expected it to work.
SvelteApplication isn't a FormApplication. In
getData
there is no this.object
hence it will be undefined and effect
is undefined and the error is pretty clear why this doesn't work.
You've probably used TRL / SvelteApplication correctly at some point. Is this how you've done things in the past?Good question. I'll have another go. I wasn't thrilled with my weird prize.
I haven't worked with active effects, but if Foundry v12 is using the FormApplication constuctor format then it's a document followed by the app options. Create a
TJSDocument
from the doc sent into the constructor and attach it as a context to the app shell / component you are loading.
Remove the getData
/ _updateObect
as that is copy / pasted code not relevant. Also take out the template
/ tabs
/ dragDrop
options being set in defaultOptions
.
I can't write the code for you this time or at least test it. The below is pseudo-code I just typed out. I'm assuming Foundry is following the FormApplication constructor.
It looks like this though:
Then in FFActiveEffectShell
:
Thanks for that. I'll try it out. I think the reason I had such a mess is I let Cursor AI run wild with it.
Yeah... Don't do that.. 😮
I seem to have first evidence of success with that. Thanks for your help!
A few weird things:
1. For ItemSheet and ActorSheet, the name of the item / actor seems to end up in the application title by default. But not so with ActiveEffect. I'm surprised that it does for item / actor since the sheet is entirely custom. Also don't understand why it then doesn't for ActiveEffect. Any thoughts?
2. It didn't like
doc: this.#doc
– I don't think one can use this
in a static method.
3. I tried adding the title
property to the defaultOptions
but couldn't figure out how to reference the TJSDocument instance (or for that matter, the class's properties, within defaultOptions
). So I can only give it text for title. The examples in essential-svelte-esm
don't have dynamic titles either.
This is how Cursor AI solved the problem:
Not sure if that's optimal – also not sure wtf is going on in there – but it does work.You are not going to get anything of value from Cursor AI. Even if you can get something to "work" it's likely shit code like every code snippet you have brought up in this post. I have no time to debug much of what you come up with especially when AI is involved. Crititcal thinking is a foundational and very important part of actually being a programmer and you need to start exercising that muscle.
Previously above I wrote out psuedo-code insofar that it should look similar. I did this from Discord quickly.
context
and props
can be defined as a normal function and are invoked with the this
of the app instance. What I did not write out correctly is that this function needs to return an object.