Absolutely new to all of this, need help with a silly query.

Hello! I'm extremely new to all of this, and i'm having issues trying to understand how to code a way for the system to calculate the health of my character sheets. I've created in template.json an Actor and modified the "base" template to include the attribute "Health" which is composed of: "health": { "value": 10, "min": 0, "max": "@attributes.maxHealth" }, and that leads down to "character": { "templates": ["base"], "attributes": { "level": { "value": 1 }, "maxHealth":{ "formula":"72 + (@abilities.for.value * 8)", "min": 0 } }, The thing is, i have an ability called "for", short for Fortitude. And when i create an Actor in my test environment, it spits out the literal "72 + (abilities.for.value * 8" as a Text. How would i go on to actually make it do the math? Thank you beforehand for taking the time to read this!
F
Forien•62d ago
I might be wrong, but I think template is now deprecated in favor of Data Models, which is preferred. Not saying using templates is wrong, but its old way of doing it. Anyway, I do not see your entire template here, so not 100% sure on cause, but assuming fortitude is defined leave one question: have you added fortutide to Roll Data? 🤔
AB
Ashby Blackburn•62d ago
Ah, Hello! Disregarding the part of my table that includes Items, my Template file looks like this:
"Actor": {
"types": ["character", "npc"],
"templates": {
"base": {
"health": {
"value": 10,
"min": 0,
"max": "72+(@abilities.for.value * 8)"
},
"light": {
"value": 5,
"min": 0,
"max": 5
},
"stagger": {
"value": 5,
"min": 0,
"max": 5
},
"sanity": {
"value": 5,
"min": 0,
"max": 5
},
"biography": ""
}
},
"character": {
"templates": ["base"],
"attributes": {
"level": {
"value": 1
}
},
"abilities": {
"for": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/FortitudeIcon.webp"
},
"pru": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/PrudenceIcon.webp"
},
"jus": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/JusticeIcon.webp"
},
"cha": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/CharmIcon.webp"
},
"ins": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/InsightIcon.webp"
},
"tem": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/TemperanceIcon.webp"
}
}
},
"npc": {
"templates": ["base"]
}
},
"Actor": {
"types": ["character", "npc"],
"templates": {
"base": {
"health": {
"value": 10,
"min": 0,
"max": "72+(@abilities.for.value * 8)"
},
"light": {
"value": 5,
"min": 0,
"max": 5
},
"stagger": {
"value": 5,
"min": 0,
"max": 5
},
"sanity": {
"value": 5,
"min": 0,
"max": 5
},
"biography": ""
}
},
"character": {
"templates": ["base"],
"attributes": {
"level": {
"value": 1
}
},
"abilities": {
"for": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/FortitudeIcon.webp"
},
"pru": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/PrudenceIcon.webp"
},
"jus": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/JusticeIcon.webp"
},
"cha": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/CharmIcon.webp"
},
"ins": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/InsightIcon.webp"
},
"tem": {
"value": 0,
"imagePath": "systems/pmtrpg/assets/TemperanceIcon.webp"
}
}
},
"npc": {
"templates": ["base"]
}
},
As to whether it's in the "Roll Data" or not, i'm not too sure? I mean, i've been able to use it to have the system give me the ability modifier and roll a check based off of it. And as to the part where you say that Data Modles is preferred while template is deprecated, i'd love to update to Data Models! I just don't know where to- start? I followed the Foundry Wiki and it lead me down to Boilerplate, and when i downloaded Boilerplate and checked the wikis and such the very first thing i came across was this file formatting itself.
F
Forien•62d ago
you need to modify the Actor#getRollData() to properly handle Roll Data. Other things you have probably work because they were in the boilerplate already Also I do not know what system you are making, but abilities is something that is more like dnd keyword, you should probably use term specific for your system (attribute, characteristic, stat etc.) to not confuse GMs and players
AB
Ashby Blackburn•62d ago
Lets see if i'm, getting this right. I changed the max in the templates base value back to "100" since it doesn't really matter, or well, it shouldn't given the fact that getRollData will replace it. So in template.json file, health looks like this:

"health": {
"value": 10,
"min": 0,
"max": 100
},

"health": {
"value": 10,
"min": 0,
"max": 100
},
Ahh, i see. That's in the actor.mjs file. It's still very much in it's template values form. Changing it up a bit, i think i'm on the right track? Though the change i made to the code in there doesn't seem to be affecting anything.
_getCharacterRollData(data) {
if (this.type !== 'character') return;

// Copy the ability scores to the top level, so that rolls can use
// formulas like `@str.mod + 4`.
if (data.abilities) {
for (let [k, v] of Object.entries(data.abilities)) {
data[k] = foundry.utils.deepClone(v);
}
}
const forAbility = data.abilities.for.value;
const healthFormula = 72 + (forAbility * 8);
data.health = {
value: 0,
min: 0,
max: healthFormula
};
// Add level for easier access, or fall back to 0.
if (data.attributes.level) {
data.lvl = data.attributes.level.value ?? 0;
}
}
_getCharacterRollData(data) {
if (this.type !== 'character') return;

// Copy the ability scores to the top level, so that rolls can use
// formulas like `@str.mod + 4`.
if (data.abilities) {
for (let [k, v] of Object.entries(data.abilities)) {
data[k] = foundry.utils.deepClone(v);
}
}
const forAbility = data.abilities.for.value;
const healthFormula = 72 + (forAbility * 8);
data.health = {
value: 0,
min: 0,
max: healthFormula
};
// Add level for easier access, or fall back to 0.
if (data.attributes.level) {
data.lvl = data.attributes.level.value ?? 0;
}
}
The part that i added is all that there is on the character roll data starting on const forAbility = data.abilities.for.value; all the way to the max: healthFormula parameter Though i wouldn't worry too much about responding to my query here, as i'm looking into the whole DataModels thing that you mentioned. Is there any resource or wiki that i could utilize to learn it?
F
Forien•62d ago
I do not know too much about WIki. There is some information about it on Foundry's Knowledge Base. Otherwise you could take a look at DND 5e 3.0.0+, or at effect refactor branch of WFRP4e, as both systems switched/are switching to Data Models (other systems probably as well, but I'm not as familiar) I do not know about the method you showed, all I know is that Actor#getRollData() method should return an object of key-value pairs that will be used by rolls, where @something.is.here would be a something.is.here key/path in that object.
AB
Ashby Blackburn•62d ago
got you, many thanks for the help!
Want results from more Discord servers?
Add your server
More Posts
Hi, friends! I'd like to build a moduleHi, friends! I'd like to build a module and I could use a shove in the right part of the docs to go Well now I'm downloading lancerWell now I'm downloading lancerNew Entertainer - Fantasy if not Table Top ---- yetMy grandson is 11, and he has started making video shorts. This is his first full length YouTube stBoilerplate.css fileHi I started a new system from the Boilerplate system, and am having an issue seeing updates from myNewbie question on scopeHey there, total newbie here. I'm a complete amateur to programming. I've completed the todo tutoriaHaving trouble to get scripts loadedTrying to make my first module and I have troubles getting anything loaded in Foundry. Here is what Help Needed! Dynamic Table for Reputation TrackingHello, everyone. I am still encountering an issue with my Reputation Tracking system. In the actor Newbie questions on testing.Hi all, ive put together a simple module for PF2E that allows a user to favorite a spell, feat, itemTrouble with Synthetic Actors (unlinked tokens)When I create a token from an actor and try to update something like its hp, I get the following errAvoid Sheet Re-render When Editing Actor's Item**TL;DR** How do I avoid a re-render of a character sheet with actor.items displayed, that happens wHow to Create & Save Custom Field Values from a Dropdown on Actor sheet?I am building a custom system for a Hogwarts setting using the Wands & Wizards 5e supplement. I am cFinding target when making an attackI’m developing a game system, and can’t figure it out, when there is combat active and a player is tTrying to register a new systemHey everyone, I am new to Foundry system development. I am working with the boilerplate system and hMinimise Document using PrototypeQuick question, I've got no idea what I'm doing so please excuse my ineptitude. Say I have a documenNew to System Development but have done minor module developmentI am trying to see if there is a complete working model of a system that I could use a base to undercalculating range/distanceI am trying to calculate the distance between two tokens to make sure they are in range of one anothPartial RerollI am looking for a way to partially "reroll" a roll. Quick example: Player rolls 2d6 (a 2 and a 5) atiered status effectsIf I have a status effect that can come from an ability, for example, burning comes from an ability Importing an npm package into a foundry systemimport minimist from 'minimist'; That line alone when included in my module's hook file is resultin(Paid) System Dev AssistanceHello, I am developing a new game and would like to build my own game system in foundry vtt. I'm not