Hi GiGs! So I have a script, triggered by a targeted macro, that causes a blank sheet (through a linked token) to set some quick and dirty stats for an NPC. This is the function I have been using for some time to get and set attributes on a character... // Get or Create an attribute from/on the character
const getOrCreateAttribute = (name, cid) => findObjs({
type: 'attribute',
characterid: cid,
name: name
}, {caseInsensitive: false})[0] || createObj('attribute',{
characterid: cid,
name: name
}); I believe I got it from someone on this community forum. Can' t recall who. So the script writes all the stats fine. But then, at the very end of the script, it generates a random name for the NPC and plops this into the character_name field. Or at least it's supposed to. But instead, it writes a whole new stat by the same name (character_name). This is the segment at the end of my API script where I identify the attribute object and set it to the new name (or at least that's what it's supposed to do)... sID = (The ID string of the character)
sCName = (The new randomly generated name)
// Set Name
let oName = getOrCreateAttribute("character_name",sID);
oName.set("current",sCName); This is the result: It writes the name as a new attribute... ...and doesn't change the name of the character at all... ...Nor does it change the name of the character container object, which should change also if you use character_name . Which is really weird behavior that I've never seen before. Am I missing something here? This should be a pretty straightforward attribute change. GiGs said: Can you describe more what you are trying to do? I don't understand when you say: I can't seem to find the attribute title used for the character's name. I thought it was pretty much always character_name . But that just creates a new attribute by that name. How is the new character name is created? What is being done to make that happen?