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

[help] Working on modifying the pathfinder character sheet script

Ok so I want to be able to use the max section of attributes for magic or temporary modifiers for skills and the such. So I know how to write the macro so it pulls the characters max as well as the current. Ok so let us say my characters name is Tom for simplicities sake. So i would like the new skills to show up written as follows /r 1d20+@{Dex-Mod}+@{Tom|Dex-Mod|max}+@{Acrobatics-Ranks}+@{Tom|Acrobatics-Ranks|max}+@{AC-Penalty} I know I could alternately have them say selected instead of toms name and this i could do. However I would like them to be character specific so no need to make sure your token is selected for every roll you make. ok so the code for having them say selected i have malikai.createAbilityAction = function createAbilityAction(skill, charType) { var abilityAction = skill.name; abilityAction += "\n/r "; abilityAction += malikai.diceType; abilityAction += "+@{" + skill.attribute + "}"; abilityAction += "+@{selected|" + skill.attribute +"|max}" abilityAction += "+@{" + skill.rank + "}"; abilityAction += "+@{selected|" + skill.rank + "|max}"; abilityAction += malikai.getSkillBonus(skill, charType); if (skill.acpan) { abilityAction += "+@{" + malikai.attribs["acpan"].name + "}"; } return abilityAction; anyhow I want to know how to reference the character name in place of the part of the string adding selected. This is what i can not figure out thanks for any help.
You should track down Emile L. ;-) Mega script nerd... Right Emile? ;-)
1382486616
Lithl
Pro
Sheet Author
API Scripter
In order to get character's name (or, any Roll20 object), you need some identifying information about the character. You need enough information to uniquely identify the character; the character ID is the minimal amount needed, but that may or may not be available. The attributes of a character object are: _id, _type, _avatar, name, bio, gmnotes, archived, inplayerjournals, and controlledby. _type is useful, but only for cutting down on execution times (all characters have _type="character"). _id is perfect, but you may not know it (each Roll20 object has a different _id). You're unlikely to have _avatar, bio, or gmnotes unless you already have the character object. The archived attribute is most likely going to be true for all relevant characters, so that's not useful. inplayerjournals and controlledby are both lists of player ids (or "all" if the character is in every player's journal/controlled by everyone). If each player controls only one character (and you know who's triggering the script), you can simply search for the character controlled by that player: var playerid = msg.playerid; // This would be for some code in an on('chat:message'...) event var character = findObjs({ _type: 'character', controlledby: playerid }); var name = character.get('name') Another option could be to use an object which is storing the character's ID already: attributes and abilities both do this. var attrib = ...; // Obtain a reference to the attribute (or, alternatively, the ability) var character = getObj('character', attrib.get('characterid')); var name = character.get('name');
1382529495

Edited 1382529991
Hi Owl, i will post the answer in this thread :D You can extend the createAbilityAction by adding the character as parameter. malikai.createAbilityAction = function createAbilityAction( character , skill, charType) { var abilityAction = skill.name; abilityAction += "\n/r "; abilityAction += malikai.diceType; abilityAction += "+@{" + skill.attribute + "}"; if (character) { abilityAction += "+@{" + character.name + "|" + skill.attribute + "|max" + "}"; } abilityAction += "+@{" + skill.rank + "}"; abilityAction += malikai.getSkillBonus(skill, charType); if (skill.acpan) { abilityAction += "+@{" + malikai.attribs["acpan"].name + "}"; } return abilityAction; } In addtion to this change, you have to change the function " retrieveUserModifiers " to detect manually added modifiers. Pass the available character object to the function and replace the max Modifier. malikai.retrieveUserModifiers = function retrieveUserModifiers(character, currentSkill, actionCommand) { var modifier = actionCommand.replace(currentSkill.name+"\n/r " + malikai.diceType + "+@{" + currentSkill.attribute + "}" + "+@{" + currentSkill.skill + "}", ""); modifier = modifier.replace("+@{" + character.get("name") + "|" + currentSkill.attribute + "|max}", ""); log("Modifier - Step 1: " + modifier); modifier = modifier.replace("+@{" + malikai.attribs["csb"].name + "}", ""); log("Modifier - Step 2: " + modifier); modifier = modifier.replace("+@{" + malikai.attribs["acpan"].name + "}", ""); log("Modifier - Step 3: " + modifier); return modifier; } I will try to test this steps, but it should be enough to guide you to the answer. //Malikai
To Malikai: I will try this out tomorrow and get back to you but thank you for working on it. I have been continuing my java script courses so can better read what is going on where but still had not figured this one out. To Brian: I played some with your method Brian but am not skilled enough to get it to work for me. Once I play with this I will repost and let you know how it is going again thanks for the help.
1382843638

Edited 1382843757
Ok so i have finally started to play with it and I am not getting the results i was hoping for. I think there may be a timing issue but I am not sure. When I use the new code in place of the old I am getting all character names to show up as undefined, not an error in the API output but the macro comes out with the word undefined instead of the characters name. I am gonna keep playing and see what i can come up with.