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] Get all repeating fields off all character sheets

1414269928

Edited 1414270195
DXWarlock
Sheet Author
API Scripter
This has to be a simple script thats just eluding me on how to do correctly. Im trying to grab all of one column in 3 repeating fields on all PC assigned character sheets to log window using a !skills command. Im gathering a list of all skills my players have to make a excel sheet quick glance list so I can work more of their skills into the game knowing what they have. But I cannot seem to figure out a way to make it read the first column on 3 repeating fields, on all sheets assigned to a PC. This is the part I'm trying to log: I know the repeating field names, the repeating stat name (first row of each) but just cant get the pieces to seem to fall together to get it to do what I need..for example OCC skills field is "repeating_OCCSK" and the first column (name) is "attr_OCCSK" and so on for the other 2. Any of the api/javascript gurus have any snippets I can start from?
1414278628
The Aaron
Roll20 Production Team
API Scripter
I've been meaning to look into this myself. I'll see what I can figure out after the kids are in bed.
1414287670
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
I went through this a while back.... should be something like this (this get based on graphics.) getvalues = function() { findCharacterByGraphics(); _.each(characters, function(indexCharacters) { var characterID = indexCharacters[0].get("_id"); var attributes = findObjs({type: "attribute", _characterid: characterID}); _.each(attributes, function(indexAttributes) { var attName = indexAttributes.get("name") if(attName.indexOf("repeating") > -1){ sendChat("API", "/direct " + indexAttributes.get("name") + ": " + indexAttributes.get("current")) }; }); }); };
1414366520

Edited 1414366886
DXWarlock
Sheet Author
API Scripter
Thanks! That helped quite a bit. I was able to use that bit to get it to find the ones I needed only and its percentage from the last row, and put them all in a <div> box so I could copy it all directly from chat as one long line separated list :) Saved me hours and hours of typing out 300+ skills for them all! Ill toss mine in here to give back, incase anyone wants to borrow some of it. it grabs only ones with the right name, then finds the appropriate box for the % and makes one line entry of text for them. Its probably not the easiest way to do it. but maybe some part of it will help someone else out. if (msgTxt.indexOf("!skills") !== -1) { var Oskills = ""; var Rskills = ""; var Sskills = ""; var token = getObj('graphic', msg.selected[0]._id); var oCharacter = getObj('character', token.get("_represents")); var name = (oCharacter.get('name')); var attributes = findObjs({type: "attribute",_characterid: oCharacter.id,}); _.each(attributes, function (indexAttributes) { var attName = indexAttributes.get("name"); if (attName.indexOf("repeating_occsk_") > -1 && attName.indexOf("OCCSKPL") == -1 && attName.indexOf("OCCSKP") == -1) { var Otemp = name + " * " + indexAttributes.get("current"); var Operc = indexAttributes.get("name"); Operc = Operc.slice(0, - 5) + "OCCSKP"; var OtempP = findObjs({_type: "attribute",name: Operc, _characterid: oCharacter.id})[0]; OtempP = " -- " + OtempP.get("current") + "<br>"; Oskills = Oskills + Otemp + OtempP; }; }); _.each(attributes, function (indexAttributes) { var attName = indexAttributes.get("name") log(attName); if (attName.indexOf("repeating_ocrcsk_") > -1 && attName.indexOf("OCRCSKp") == -1 && attName.indexOf("OCRCSKPL") == -1) { var Rtemp = name + " * " + indexAttributes.get("current"); var Rperc = indexAttributes.get("name"); Rperc = Rperc.slice(0, - 6) + "OCRCSKp"; var RtempP = findObjs({_type: "attribute",name: Rperc, _characterid: oCharacter.id})[0]; RtempP = " -- " + RtempP.get("current") + "<br>"; Rskills = Rskills + Rtemp + RtempP; }; }); _.each(attributes, function (indexAttributes) { var attName = indexAttributes.get("name"); if (attName.indexOf("repeating_secsk_") > -1 && attName.indexOf("SECSKp") == -1 && attName.indexOf("SECSKpl") == -1) { var Stemp = name + " * " + indexAttributes.get("current"); var Sperc = indexAttributes.get("name"); Sperc = Sperc.slice(0, - 5) + "SECSKp"; var StempP = findObjs({_type: "attribute",name: Sperc, _characterid: oCharacter.id})[0]; StempP = " -- " + StempP.get("current") + "<br>"; Sskills = Sskills + Stemp + StempP; }; }); var whoC = OuterDiv + iPart + "background-color:#222222;'>" + Oskills + "</div>"; sendChat('Picked', "/direct " + whoC); var whoC = OuterDiv + iPart + "background-color:#222222;'>" + Rskills + "</div>"; sendChat('Picked', "/direct " + whoC); var whoC = OuterDiv + iPart + "background-color:#222222;'>" + Sskills + "</div>"; sendChat('Picked', "/direct " + whoC); };