new consumable types

ZZhell3/1/2022
Tried adding localization strings for some new consumable types, but keep getting this ("DND5E.Consumable[...]") no matter what. I'm 99% I have followed all guides on localization to the point. en.json in the module.json, etc etc, with all the needed strings inside.
No description
CCalego3/1/2022
How are you adding new consumable types?
ZZhell3/1/2022
Hooks.on('ready'), overriding CONFIG.DND5E.consumableTypes
CCalego3/1/2022
kk, looks like CONFIG.DND5E.consumableTypes has the output of game.i18n.localize cached during setup hook, So adding to that after that point you'll need to provide the already-localized versions
CCalego3/1/2022
https://gitlab.com/foundrynet/dnd5e/-/blob/master/dnd5e.js#L149 This little thing does that, it runs through the CONFIG.DND5E keys provided and replaces the values with their localized versions
GitLab
dnd5e.js 路 master 路 Foundry Network / Foundry VTT 5th Edition
An implementation of the Dungeons & Dragons 5th Edition game system for Foundry Virtual Tabletop (http://foundryvtt.com). This work is permitted under the Open...
ZZhell3/1/2022
I'd just add that hook (on 'setup'?), as is, with localizeKeys and sortKeys = ['consumableTypes'] ? Easy as that? 馃
CCalego3/1/2022
nono, you'd want something like this:
Hooks.on('ready', () => {
CONFIG.DND5E.consumableTypes = {
foo: game.i18n.localize('MY_KEY')
}
})
Hooks.on('ready', () => {
CONFIG.DND5E.consumableTypes = {
foo: game.i18n.localize('MY_KEY')
}
})
the important thing is that you do the game.i18n.localize part yourself, since the 5e system believes it doesn't need to when it uses values from CONFIG.DND5E.consumableTypes
ZZhell3/1/2022
What is MY_KEY in this example? Tried CONFIG.DND5E.consumableTypes.elixir = game.i18n.localize("DND5E.ConsumableElixir") in the console as a test, but that changes its name to... well DND5E.ConsumableElixir
CCalego3/1/2022
MY_KEY is a localization key you would define in your module's en.json. I wouldn't recommend using DND5E.Whatever as that implies it was added by the dnd5e package. Here's a more complete example:
// en.json
{
"my-module-id": {
"ELIXIR": "Elixir"
}
}
// en.json
{
"my-module-id": {
"ELIXIR": "Elixir"
}
}
Hooks.on('ready', () => {
CONFIG.DND5E.consumableTypes = {
elixir: game.i18n.localize('my-module-id.ELIXIR'),
somethingElse: "Something Else that Isn't Localized", // also works, just can't be translated
}
})
Hooks.on('ready', () => {
CONFIG.DND5E.consumableTypes = {
elixir: game.i18n.localize('my-module-id.ELIXIR'),
somethingElse: "Something Else that Isn't Localized", // also works, just can't be translated
}
})
// after the `ready` hook:
console.log(CONFIG.DND5E.consumableTypes.elixir); // Expected: "Elixir"
console.log(CONFIG.DND5E.consumableTypes.somethingElse); // Expected: "Something Else that Isn't Localized"
// after the `ready` hook:
console.log(CONFIG.DND5E.consumableTypes.elixir); // Expected: "Elixir"
console.log(CONFIG.DND5E.consumableTypes.somethingElse); // Expected: "Something Else that Isn't Localized"
You could do this in your en.json:
{
"DND5E.ConsumableElixir": "Elixir"
}
{
"DND5E.ConsumableElixir": "Elixir"
}
To make what you pasted here work, but this is not recommended.
ZZhell3/1/2022
But that is what I had done. 馃
CCalego3/1/2022
curious can you paste what you've got in here? or is it hosted somewhere we can see?
ZZhell3/1/2022
en.json?
CCalego3/1/2022
and the bit of your js that deals with the hook
ZZhell3/1/2022
{
"DND5E.ConsumablePotionTonic": "Tonic",
"DND5E.ConsumablePotionSalve": "Salve",
"DND5E.ConsumablePotionPill": "Pill",
"DND5E.ConsumablePotionWine": "Wine",
"DND5E.ConsumablePoisonIngested": "Ingested Poison",
"DND5E.ConsumablePoisonInhaled": "Inhaled Poison",
"DND5E.ConsumablePoisonInjury": "Injury Poison",
"DND5E.ConsumablePoisonContact": "Contact Poison",
"DND5E.ConsumableDrink": "Drink",
"DND5E.ConsumableTrap": "Trap",
"DND5E.ConsumableBomb": "Bomb",
"DND5E.ConsumableElixir": "Elixir",
}
{
"DND5E.ConsumablePotionTonic": "Tonic",
"DND5E.ConsumablePotionSalve": "Salve",
"DND5E.ConsumablePotionPill": "Pill",
"DND5E.ConsumablePotionWine": "Wine",
"DND5E.ConsumablePoisonIngested": "Ingested Poison",
"DND5E.ConsumablePoisonInhaled": "Inhaled Poison",
"DND5E.ConsumablePoisonInjury": "Injury Poison",
"DND5E.ConsumablePoisonContact": "Contact Poison",
"DND5E.ConsumableDrink": "Drink",
"DND5E.ConsumableTrap": "Trap",
"DND5E.ConsumableBomb": "Bomb",
"DND5E.ConsumableElixir": "Elixir",
}
custom-itemTypes.mjs:
Hooks.on('ready', () => {
if(!game.settings.get(MODULE_NAME, SETTING_NAMES.REPLACE_CONSUMABLE_TYPES)) return;

CONFIG.DND5E.consumableTypes = {
ammo: "Ammunition",
bomb: "Bomb",
drink: "Drink",
food: "Food",
poison: "Poison",
poisonContact: "Contact Poison",
poisonIngested: "Ingested Poison",
poisonInhaled: "Inhaled Poison",
poisonInjury: "Injury Poison",
potion: "Potion",
potionTonic: "Tonic",
potionSalve: "Salve",
potionPill: "Pill",
potionWine: "Wine",
scroll: "Scroll",
trap: "Trap",
trinket: "Trinket",
elixir: "Elixir"
};
});
Hooks.on('ready', () => {
if(!game.settings.get(MODULE_NAME, SETTING_NAMES.REPLACE_CONSUMABLE_TYPES)) return;

CONFIG.DND5E.consumableTypes = {
ammo: "Ammunition",
bomb: "Bomb",
drink: "Drink",
food: "Food",
poison: "Poison",
poisonContact: "Contact Poison",
poisonIngested: "Ingested Poison",
poisonInhaled: "Inhaled Poison",
poisonInjury: "Injury Poison",
potion: "Potion",
potionTonic: "Tonic",
potionSalve: "Salve",
potionPill: "Pill",
potionWine: "Wine",
scroll: "Scroll",
trap: "Trap",
trinket: "Trinket",
elixir: "Elixir"
};
});
CCalego3/1/2022
I take back half of what I have said
ZZhell3/1/2022
馃槵
CCalego3/1/2022
https://gitlab.com/foundrynet/dnd5e/-/blob/master/module/apps/ability-use-dialog.js#L169 Here's where the string that's displayed is being composed. Spot the problem
GitLab
module/apps/ability-use-dialog.js 路 master 路 Foundry Network / Foun...
An implementation of the Dungeons & Dragons 5th Edition game system for Foundry Virtual Tabletop (http://foundryvtt.com). This work is permitted under the Open...
CCalego3/1/2022
type: game.i18n.localize(`DND5E.Consumable${item.data.consumableType.capitalize()}`),
type: game.i18n.localize(`DND5E.Consumable${item.data.consumableType.capitalize()}`),
Instead of assuming that the value desired is in CONFIG.DND5E.consumableTypes... the localization string is constructed ad-hoc out of the consumable type on the item. sigh SO, You definitely need to add these strings to the en.json with the DND5E. prefix And, since this doesn't really care about the consumableTypes value, you need to make sure your key is structured so that it's going to work with that capitalize()
ZZhell3/1/2022
ie 'elixir' should work but not 'potionPill'
CCalego3/1/2022
"DND5E.ConsumablePotionTonic": "Tonic", Might need to be: "DND5E.ConsumablePotiontonic": "Tonic", capitalize apparently isn't a normal string method... so I can't tell but in-foundry try this from console:
'potionTonic'.capitalize()
'potionTonic'.capitalize()
ZZhell3/1/2022
returns 'PotionTonic'
CCalego3/1/2022
wtf
ZZhell3/1/2022
馃し
No description
CCalego3/1/2022
so then potionTonic would end up looking for DND5E.ConsumablePotionTonic, which you have...
ZZhell3/1/2022
Yeah and Elixir, Bomb, etc etc, they should all work (... also apparently 'ammo' doesn't work either. I didn't add that, I just kept it in because I wanted to keep it)
CCalego3/1/2022
Ok, you said you tried game.i18n.localize(... from console and it didn't do it? like just as a test of the localization setup
ZZhell3/1/2022
No description
ZZhell3/1/2022
Interestingly...
No description
ZZhell3/1/2022
and just for good measure
No description
CCalego3/1/2022
if there's no key found it spits back what you give it show me your module manifest in full
ZZhell3/1/2022
{
"name": "zhell-custom-stuff",
"title": "Zhell's Custom Stuff",
"description": "Personal module for replacing or adding to many things. Modular.",
"version": "3.83",
"author": "Zhell",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "9",
"packs": [
{
"name": "base-items",
"label": "Base Items",
"path": "./packs/base-items.db",
"entity": "Item",
"type": "Item"
}
],
"esmodules": [
"./setup.js",
"./scripts/custom-conditions.mjs",
"./scripts/custom-languages.mjs",
"./scripts/custom-profs.mjs",
"./scripts/custom-progression.mjs",
"./scripts/custom-recharge.mjs",
"./scripts/custom-itemTypes.mjs"
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "languages/en.json"
}
]
}
{
"name": "zhell-custom-stuff",
"title": "Zhell's Custom Stuff",
"description": "Personal module for replacing or adding to many things. Modular.",
"version": "3.83",
"author": "Zhell",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "9",
"packs": [
{
"name": "base-items",
"label": "Base Items",
"path": "./packs/base-items.db",
"entity": "Item",
"type": "Item"
}
],
"esmodules": [
"./setup.js",
"./scripts/custom-conditions.mjs",
"./scripts/custom-languages.mjs",
"./scripts/custom-profs.mjs",
"./scripts/custom-progression.mjs",
"./scripts/custom-recharge.mjs",
"./scripts/custom-itemTypes.mjs"
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "languages/en.json"
}
]
}
CCalego3/1/2022
oh you're gonna hate this
"DND5E.ConsumableElixir": "Elixir",
}
"DND5E.ConsumableElixir": "Elixir",
}
trailing comma
ZZhell3/1/2022
You're right.
CCalego3/1/2022
did that do it?
ZZhell3/1/2022
Gonna test real quick, but hold on, there are commas in the system folder's en.json
CCalego3/1/2022
it's the trailing comma that makes JSON mad i.e. the last one shouldn't have a comma, the rest should
ZZhell3/1/2022
oh gosh darn it
CCalego3/1/2022
yup may I recommend #screaming-into-the-void that was a journey lol
ZZhell3/1/2022
It works now. facepalmpicard Thank you.
CCalego3/1/2022
happy to help 馃檪

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
spell-compendium-5e alpha1Overriding onDropItem & onSortItemYou'd override them in your sheet class.getter & setter wrapper for settingsI'm trying to use a getter & setter pair as an interface for `game.settings.get` and `game.settings.scrollable tab contentsIt is possible, and you're firmly in the css and DOM structure side of development with this line ofJr devI'm cleaning out my bookmarks and accidentally came back to this article. Potentially useful startinHTCPackage: `hero-creation-tool`System Specific CSSI'm not 100% about this, but it is worth watching out that your solution doesn't actually end up beiadvancement-wipCommander register apitalking about permissions, im working on the registering api for the Commander, and I wanted to ask Azgaars Blurry MapHey all. I'm taking a look at my importer for Azgaar's Fantasy Map Generator and wondering how I canccjmk overlaybut for what I wanted I think I *needed* to append it there so that I can overlay the whole screencliits very very early alpha demoMonarch APIAlright, adventurous ones: I have a Beta version of Monarch with the new components API! Manifest: compacted chat cardsModules create problems to solve problems... Today's problem: "When I roll an attack, it eats the whdragdrop shenneneginsRight now, a user can drag a spell onto their character sheet. I store that in a 'spell' array and leffect mini modulesI've gotten to the point where I'm confident in releasing a slurry of tiny no-config Active Effect rdamage application hooksNew 5e Hook ideas, gimme yer thoughts: `Hooks.call('Actor5e.preDamageApplied')` args: `damageAmounthook conventionsRegarding hooks, is the convention that _all_ `pre...` hooks are executed on the machine that initiaexpand arraysIs there a way to `expandObject` except for an Array?edit-owned-item-effectI've made an abomination. This hacks its way past the limitations surrounding editing effects on own