League-of-Foundry-Developers / torch

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

Hooded Lantern and Bullseye Lantern doesn't work #29

Closed emmoth closed 1 year ago

emmoth commented 1 year ago

I like this plugin but for some reason it doesn't find the "Hooded lantern" or "Bullseye lantern", only Torch, Candle, Lamp, Dancing Light and Light.

I noticed that both the "Bullseye Lantern" and the "Hooded Lantern" is called "Lantern, Hooded" and "Lantern, Bullseye" at D&D Beyond, could that be the issue ?

Code copied from sources.json from v10. "Bullseye Lantern": { "name": "Bullseye Lantern", "type": "equipment", "consumable": false, "states": 2, "light": [ { "bright": 15, "dim": 45, "angle": 53 } ] }, "Hooded Lantern": { "name": "Hooded Lantern", "type": "equipment", "consumable": false, "states": 3, "light": [ { "bright": 30, "dim": 60, "angle": 360 }, { "bright": 0, "dim": 5, "angle": 360 } ]

lupestro commented 1 year ago

Since everything is governed by name, this could explain it. I used the names from the compendia supplied with the dnd5e system. One of these days, I'll need to figure out how to best support localization of the names as well. (My work on gaming stuff is suspended during NaNoWriMo this month, but will continue in December.)

However, you can add your own light sources as JSON files using the instructions in https://github.com/League-of-Foundry-Developers/torch/tree/v10 and import it through the corresponding configuration setting. This also lets you override any existing source with any cool settings you prefer - flickering, etc.

Note that the file you'd create and the sources.json delivered with the module have the same structure, so you can create your new one by copying the sources.json and trimming away anything you aren't changing, and copy/paste/adjust to add new items. I'd strongly recommend not just leaving things you haven't touched in there because I will change the data in new releases when I receive bug reports (like the one I'm about to change for the bullseye lantern) and if you leave the old data in your custom light sources JSON, then your JSON will overshadow the corrected data and you won't gain the benefit.

lupestro commented 1 year ago

@emmoth I am now considering a syntax that will improve situations like yours - a new aliases section, containing entries {originalName}: {newName}, similar to the keying of translation files. When the work is complete, the module will recognize light sources with the alias names exactly as it would sources with the original names.

Aliases would appear within a user settings JSON, within the section for the system. You can provide new sources in the same file, but you will no longer need to duplicate the entire light source entries from the sources.json just to give them new names:

{
  "dnd5e": {
    "system": "dnd5e",
    "topology": "standard",
    "quantity" : "quantity",
    "aliases:" {
      "Bullseye Lantern": "Lantern, Bullseye",
      "Hooded Lantern": "Lantern, Hooded"
    },
    "sources": {
    . . .
    }
}

Aliases will also be used as the basis for localization of light source names in the module. The module will look for and automatically read a sources-{locale}.json file for the current locale, if present. This file will contain nothing but the aliases for the base light sources for each system in that language. I will supply the one for English, with duplicate files for all the languages the module supports. I will then put out a call for folks in the regions to update the translations in the sources-{locale}.json file for their language.

In theory, then, the names of light sources in the base sources.json file could just become arbitrary names, translation keys, rather than the actual English names of the light source as found in system-supplied compendia. But I will continue to use the English names, as it does no harm.

This capability isn't present in the code as I type this, but I hope to complete this work in a release this weekend. Let me know if it looks like this will help with your situation.

Aside: We have a lot of unnecessary redundancy in the source JSON files. In this same release, I will relax the reading of the userSettings file to allow omission of the system, topology and quantity properties for any system already supported, using the original. For new systems, it will default topology and quantity values to "standard" and "quantity", respectively, and system to the name used as a key. This will ease the burden on users writing these, as they can just supply the system key with the aliases and new sources. I will also make the redundant name property on a source optional. That should make all this JSON as lean as it possibly can be.

emmoth commented 1 year ago

That sounds like a good plan.

I made a new .json file myself and added all possible lighting I could and had access too from Beyond, and named it custom_light.json

Loaded it through the module and it worked like a charm :)

{
    "dnd5e": {
      "system": "dnd5e",
      "topology": "standard",
      "quantity" : "quantity",
      "sources":{
        "Candle": {
          "name": "Candle",
          "type": "equipment",
          "consumable": true,
          "states": 2,
          "light": [
            { "bright": 10, "dim": 15, "angle": 360, "color": "#f5872e", "alpha": 0.3,
            "animation": { "type": "torch", "speed": 5, "intensity": 2, "reverse": false }
          }
          ]
        },
        "Torch": {
          "name": "Torch",
          "type": "equipment",
          "consumable": true,
          "states": 2,
          "light": [
            { "bright": 20, "dim": 40, "angle": 360, "color": "#f5872e", "alpha": 0.4,
            "animation": { "type": "torch", "speed": 10, "intensity": 5, "reverse": false }
          }
          ]
        },
        "Lamp": {
          "name": "Lamp",
          "type": "equipment",
          "consumable": false,
          "states": 2,
          "light": [
            { "bright": 15, "dim": 45, "angle": 360 }
          ]
        },
        "Lantern, Bullseye": {
            "name": "Lantern, Bullseye",
            "type": "equipment",
            "consumable": false,
            "states": 2,
            "light": [
              { "bright": 60, "dim": 120, "angle": 53 }
            ]
          },
          "Lantern, Hooded": {
            "name": "Lantern, Hooded",
            "type": "equipment",
            "consumable": false,
            "states": 3,
            "light": [
              { "bright": 30, "dim": 60, "angle": 360 },
              { "bright": 0, "dim": 5, "angle": 360 }
            ]
          },
        "Light": {
          "name": "Light",
          "type": "cantrip",
          "consumable": false,
          "states": 2,
          "light": [
            { "bright": 20, "dim": 40, "angle": 360 }
          ]
        },
        "Dancing Lights": {
          "name": "Dancing Lights",
          "type": "cantrip",
          "consumable": false,
          "states": 2,
          "light": [
            { "bright": 0, "dim": 10, "angle": 360,
            "animation": { "type": "torch", "speed": 10, "intensity": 5, "reverse": false }
          }
          ]
        }                
      }
    }
}
lupestro commented 1 year ago

@emmoth FYI, the aliases will work the other way around, which I think will be more intuitive as well as avoiding issues or complications when you need more than one new alias for a name:

{
  "dnd5e": {
    "system": "dnd5e",
    "topology": "standard",
    "quantity" : "quantity",
    "aliases:" {
      "Lantern, Bullseye": "Bullseye Lantern",
      "Lantern, Hooded": "Hooded Lantern"
    },
    "sources": {
    . . .
    }
}

In addition, because ddb-importer is such a big part of our lives, these two specific aliases will be built into the delivered module.

lupestro commented 1 year ago

@emmoth This should be fully addressed in v2.2.0. Closing issue