Global Arrays & Writable Stores
I currently have this set to use a settings array to use to pass data to the SanityApp and also check to see if the Application is live because the application is to close if the array is empty. It's "populating the app" part and checking if the array is empty part is working as intended, but the interval I have set up in the script of the SanityApp appears to not be working as it's not updating automatically. SanityApp and SanityApplication.js
16 Replies
Include a repo link as well if you can.
I haven't gotten into the "making branches" part of my learning just yet and don't want to overwrite what is there. I will sort that out tonight though.
I'll have to see how you are initializing the game setting. There may be a Foundry gotcha there if it is a world setting. IE world settings are only modifiable by GM users and not normal users though normal users can read world settings. This is just how Foundry works. As long as it is the GM account that is modifying a world store then this should be fine.
Then there is finding the appropriate existing store / Foundry integration aspect w/ TRL to use vs what you currently have attempted.
I’m currently registering with socketLib and the player clients send the request via socket. After that it’s all handle on the GM’s side.
That's good. Also in general I recommend not using an additional module dependency. Something like this should be easy to create the raw
socket.io
code.I have checked the current state code for function in this way and they can loaded the app in the older version before I started this “app expansion” part I’m doing now. Currently it just opens a new app with each incoming request.
TRL does have reactive game settings integration which should make this easy..
Even better is that there is a reactive world setting array / object store in the standard library that is quite likely what you'll want to use. See: WorldSettingArrayStore.
Automated Animations uses it, but like most sample code it's not always best to point you to it as a simple / copy / paste example:
https://github.com/otigon/automated-jb2a-animations/blob/dd66d205d4699c03b7dfc5a134c5196218360bfe/src/formApps/_AutorecMenu/store/category/CategoryStore.js#L7
The AA module is a bit complex; I also will be helping update it after
0.2.0
drops.Alright. After this one is complete and more functionality added, this is just the dialog app side, I have a Feat -> Talents conversion module to start which will heavily use svelte and a master automation module to flesh out.
This one here is my first module I need to get registered with FVTT
https://github.com/Relic-Repo/Fates-Folly
https://github.com/Relic-Repo/Fates-Folly
Just a quick tip... When putting links into Discord surround them with
<>
like <URL>
to not show the large breadcrumb image. Also you can use [some text](<URL>)
to create a link from the text name which is handy.Oh cool learned something new
Lots of new stuff incoming re: Svelte & TRL! 😄
I got it working. Well to be honest the "import { writable } from 'svelte/store';" was working all along, it was the dumb human. See the code is sett up to take the Save/Test data after a player rolls a save and adds it to an array I have in settings. If the array is empty it also calls the SanityApp. The SanityApp reads the global array sets up the writable store to watch for changes. The handleRoll and handleCancel are set up respectively add the form data nad completes the roll and the later just passes the roll along. But they both remove their reference entry from the settings array. As other players roll it sees teh array is not empty and just appends the new request object. Wellllll if the App is closed like it would be on a refresh, but the array isn't empty because you haven't been going through all of the form process. So yeah it dawned on me to check the array and sure enough it was loaded down. After I cleared it function returned.
Adding a clear array on setup hook too
Going to add an option to expand this to all d20 tests.
If you are happy with your code that is great. Good job getting it to work. As mentioned though there are cleaner solutions that are more functional in TRL to solve this particular problem and provide more flexibility. A large part of TRL is optional / use what you need. The one thing I can't do much of is debug custom code that you write.
It's coming along nicely. I will soon be ready to push the change to GitHub and I'll post code then. I'm sure there are many shorter paths, but the failing is my teacher lol
Getting on the struggle bus is definitely the way to learn. Perhaps we can circle around after
0.2.0
drops and see how things can be tighened up. 😄I added in an indicator/toggle for the GM for those players that rolled the wrong thing. Check is Blue and Orange is Save. The button will toggle to fix those types of in game play errors.
Current state https://github.com/Relic-Repo/Fates-Descent