League-of-Foundry-Developers / torch

Simple torch module for Foundry VTT
10 stars 16 forks source link

PF2E custom light sources #79

Open Cedric-the-Destroyer opened 2 months ago

Cedric-the-Destroyer commented 2 months ago

It would be endlessly helpful, to be able to attach items/item ID to the settings, to create custom light sources. As it stands, I spent 3 hours tonight trying to get the json to work, and while I recognize I am probably doing it wrong, I really tried to make it work. My solution as of tonight is to just disable this mod, and do it the way PF2E expects it to be done, which is far less nuanced than I could wish, and is much less convenient

In any case, thank you for the module, and your time.

torch_settings.json

lupestro commented 2 months ago

Message heard and noted. The trouble is that the coding involved in providing a GUI for it is a fair amount of work. However, I can do a lot pretty easily to improve the user experience for light source files.

Over the last year or so, it's become pretty clear that the light configs are a struggle. The only problem in the json you posted is the comma toward the bottom of the file, so you only "missed it by that much." Right now, you get no idea when you offer up a JSON file whether the JSON you supply is valid. That's a serious user experience problem.

The module should provide human-readable validation of the JSON file when you click the button to use it. Fortunately, there is a handy npm module called ajv that I can use to do the heavy lifting for that. Further, it can validate against a schema so it can tell not only if it is a valid JSON file, but if it is a valid light source file. Based on recent feedback, this is probably more important than any other feature I could add and is more important than any work I do for the fudge-rpg system. Consider it top-of-stack.

To broaden the definition of "right", I'm also considering supporting json5 and perhaps yaml, provided I can get a comparable level of validation. I'll need to experiment, so I'll get the ajv support out there first.

lupestro commented 2 months ago

FYI - I've coded the validation and reporting - I just have to build and run a set of test cases for it. Probably in a few days, depending how much time I can carve out during the week.

Cedric-the-Destroyer commented 2 months ago

I appreciate you taking a look at this

lupestro commented 2 months ago

As it happens, the absence of light source validation has played at least a subsidiary role in tickets 79, 78, 77, 76, 75, 45, 37, 32, 27, and 26 - the latter being about the time that multiple light sources were introduced. This provides considerable motivation for the feature. :)

Good news: As of this morning, the tests for the feature are passing and it is in a branch. I'm expecting to release it some time today.

Feature includes JSON5 and YAML support, with a pop-up both on Save Settings and on bringing up the token HUD if the configured Additional Light Sources file is either unreachable, has invalid JSON/YAML (for example, invalid characters or your braces don't match), or has invalid schema (good JSON/YAML but content has wrong data types, values out of range, wrong structure, etc.) Before I release, I need to beef up the README.md with a yaml sample. I'm guessing some folks will find that a lot easier to work with.

lupestro commented 2 months ago

Torch 2.13.0 has the JSON5 and YAML support, with a (hopefully pretty informative) error popup if there are issues with the supplied data. README.md is clarified with foot-guns removed from samples.