Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

What's the 'character_name' attribute for the official Roll20 Vampire The Masquerade 5th Ed. character sheet?

1715344501

Edited 1715345181
Hey there! So, I am making some macro API commands to set up NPCs on the fly using the official Vampire The Masquerade 5th Ed. character sheet. 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. It doesn't change the name on the character sheet, nor the name of the character object in general. There's this attribute titled  char_name_string in the list, and it contains the character name within it. But there are other odd characters around it, making it seems more like a handler attribute of some type. So I hesitate to write to it without knowing how it works. Could anyone throw me a bone on how to set an NPC character's name on the fly with API? Normally this is an easy-peasy task. But nothing I try works. Thanks in advance for any help you can provided! Michael
1715348922
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Michael! If you right-click on the name in the character sheet and choose "Inspect", you can often find the attribute nearby in the code. It will likely begin with "attr_". Delete that first part and you should have it.
1715376556

Edited 1715376838
I did try this, and it says character_name, which fails. Is it possible the sheet is over-riding anything coming from API? I can’t imagine why they would do that. And when I force it to write to character_name, even if it can’t find the original, it creates a whole new attribute by that name. Doesn’t the character sheet container always use character_name? keithcurtis said: Hi Michael! If you right-click on the name in the character sheet and choose "Inspect", you can often find the attribute nearby in the code. It will likely begin with "attr_". Delete that first part and you should have it.
1715388294

Edited 1715388360
GiGs
Pro
Sheet Author
API Scripter
The character name is always character_name. Characetr sheets might have a second attribute that also contains the character sheet name, but character_name always exists. 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?
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?
Oh, and here's the segment that generates the name, since you asked for it. I don't think it's relevant though, since as you can see by the image, it generates a name beautifully. // Set the name strings let sMa = "Liam|Noah|Oliver|James|Elijah|William|Henry|Lucas|Benjamin|Theodore|Mateo|Levi|...[snip][goes on for a total of 1000 names]"; let sFe = "Olivia|Emma|Charlotte|Amelia|Sophia|Isabella|Ava|Mia|Evelyn|Luna|Harper|Camila|...[snip][goes on for a total of 1000 names]"; let sLs = "Smith|Johnson|Williams|Jones|Brown|Davis|Miller|Wilson|Moore|Taylor|Anderson|...[snip][goes on for a total of 1000 names]"; let s1N = sMa; //<-- Default as male for 1st name; // If I Set Gender... if(sCName == "Female" || sCName == "female" || sCName == "F" || sCName == "f"){s1N = sFe;} else if(sCName == "Male" || sCName == "male" || sCName == "M" || sCName == "m"){/* Do nothing */} // Otherwise, randomly determine else{let nNN = Math.floor(Math.random() * 10) + 1; if(nNN > 5){s1N = sFe;}} // Get the First Name let a1N = s1N.split("|"); let n1R = Math.floor(Math.random() * 1000); //<-- Number between 0-999 let s1Name = a1N[n1R]||"[1st Name]"; // Get the last name let aLs = sLs.split("|"); let n2R = Math.floor(Math.random() * 1000); //<-- Number between 0-999 let s2Name = aLs[n2R]||"[Last Name]"; // Combine the name for full name sCName = s1Name+" "+s2Name;
1715402753
GiGs
Pro
Sheet Author
API Scripter
I see, it's a script that updates the name or creates one if it doesn't exist. I'm not sure why that isn't working properly. Scripts aren't my focus - I hope someone can use this information and figure out what's going on. I wonder if it's something to do with the nature of the character_name attribute, that must always exist so is automatically created for each character - it's a different kind of property, since you can delete attributes but you cannot delete this property.
Yeah, Aaron would probably know what's going on at a glance. But he must be busy. Can't seem to get a response. :( And I agree. It's likely caused by the special nature of automatic attributes like character_name. I've just never run into it before, so I have no idea how to set the name field. I just didn't want my NPCs to all be, "NPC1 and NPC2, etc. lol GiGs said: I see, it's a script that updates the name or creates one if it doesn't exist. I'm not sure why that isn't working properly. Scripts aren't my focus - I hope someone can use this information and figure out what's going on. I wonder if it's something to do with the nature of the character_name attribute, that must always exist so is automatically created for each character - it's a different kind of property, since you can delete attributes but you cannot delete this property.
Hey everyone! So, with some help from  Nora C.  and her crew over at the Roll20 team, I was able to get the API script to work. In the end, THIS little bit of javascript worked... // sID = The ID string for the character // sCName = My randomly generated name string var oChar = findObjs({ _type: 'character', _id: sID })[0]; oChar.set("name", sCName); Hopefully anyone else with this issue will find this useful. Thanks, Nora! And thanks everyone that chimed in! You guys are awesome!
1715731803

Edited 1715731875
GiGs
Pro
Sheet Author
API Scripter
wasd the main different the removal of the createAttribute call? What was the problem? Edit: oh I see, it's setting a property on the character, not the attribute.
1715744077

Edited 1715744242
Yep. Apparently " character_name " is not an attribute. It is the " _name " property of the character object. Makes SO much sense in hindsight. lol GiGs said: wasd the main different the removal of the createAttribute call? What was the problem? Edit: oh I see, it's setting a property on the character, not the attribute.
1715830389
GiGs
Pro
Sheet Author
API Scripter
That does make sense in ihindsight. One of those things were you are smacking your head going, that should have been obvious.