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

Generating UID's?

1616602748
Ernest P.
Pro
API Scripter
I am working with an existing character sheet, building an import for it. The character sheet is creating grouped blocks for skills to store various attributes, formulae, etc. about a skill. Example: {"name":"repeating_skills_-MWLlegkY4JeIY3v0dHj_skill_name","current":"Persuasion","max":"","_id":"-MWLlg0qDrMcBPapAyGc","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLlegkY4JeIY3v0dHj_skill_roll_formula","current":"&{template:hero6template} {{charname=@{character_name}}}  {{action=@{skill_name}}}  {{roll=[[3d6]]}}  {{target=8}} {{base=8}}","max":"","_id":"-MWLlg2q6SKtgnRGAF5F","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLlegkY4JeIY3v0dHj_skill_char","current":"8-","max":"","_id":"-MWLlhMr83gUJO6sCFQ_","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLlegkY4JeIY3v0dHj_skill_has_increase","current":0,"max":"","_id":"-MWLlhOpOR_nou_aRwjy","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLlegkY4JeIY3v0dHj_skill_has_roll","current":1,"max":"","_id":"-MWLlhOrlfMPJ-UxjajE","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLlegkY4JeIY3v0dHj_skill_roll_show","current":"8-","max":"","_id":"-MWLlhOv9KuH5n8GOp6a","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLlegkY4JeIY3v0dHj_skill_roll_target","current":8,"max":"","_id":"-MWLlhOxEkvuE2TGc3ll","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLmB2tLZm45hmYOQ8-_skill_name","current":"KS: Psionics","max":"","_id":"-MWLmHRAjUXDzN8sac9Q","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLmB2tLZm45hmYOQ8-_skill_roll_formula","current":"&{template:hero6template} {{charname=@{character_name}}}  {{action=@{skill_name}}}  {{roll=[[3d6]]}}  {{target=13}} {{base=9}} {{stat=3}} {{lvls=1}}","max":"","_id":"-MWLmHT1HFpILLvWP3-9","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLmB2tLZm45hmYOQ8-_skill_has_increase","current":1,"max":"","_id":"-MWLmHUlSfXSPMlq7d-v","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLmB2tLZm45hmYOQ8-_skill_has_roll","current":1,"max":"","_id":"-MWLmHUnB_TBkvUgi06K","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLmB2tLZm45hmYOQ8-_skill_roll_show","current":"13-","max":"","_id":"-MWLmHUo2QQuMpdA0cxt","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLmB2tLZm45hmYOQ8-_skill_roll_target","current":13,"max":"","_id":"-MWLmHUpvB3hQWDGDrEN","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLmB2tLZm45hmYOQ8-_skill_char","current":"INT","max":"","_id":"-MWLmHZvJbqWQrT5p82k","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWLmB2tLZm45hmYOQ8-_skill_increase","current":"0","max":"","_id":"-MWLmJ9DiTs56zd-jrIl","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, I am looking to replicate this in my import. I don't think most of it will be a problem, but I noticed they are using a GUID as part of the attribute name to group the related skill information together. How can I create a UID in my javascript code to include into name? - Ernie
1616603435
The Aaron
Roll20 Production Team
API Scripter
Here's the code for that: const generateUUID = (() => { let a = 0; let b = []; return () => { let c = (new Date()).getTime() + 0; let f = 7; let e = new Array(8); let d = c === a; a = c; for (; 0 <= f; f--) { e[f] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(c % 64); c = Math.floor(c / 64); } c = e.join(""); if (d) { for (f = 11; 0 <= f && 63 === b[f]; f--) { b[f] = 0; } b[f]++; } else { for (f = 0; 12 > f; f++) { b[f] = Math.floor(64 * Math.random()); } } for (f = 0; 12 > f; f++){ c += "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(b[f]); } return c; }; })(); const generateRowID = () => generateUUID().replace(/_/g, "Z");
1616605767
Ernest P.
Pro
API Scripter
Thank you! - E
1616646188
timmaugh
Forum Champion
API Scripter
Be still my heart. A Hero6 game?
1616701405

Edited 1616701513
Ernest P.
Pro
API Scripter
timmaugh said: Be still my heart. A Hero6 game? Hopefully a fully functioning character importer from Hero Designer. I have gotten through the characteristics and movement is working for run, swim, vertical and horizontal leap. Skills are on the plate now and once they are done the template will be pretty similar for perks, talents, complications, equipment, combat levels, etc. If you'd like to play with it, critique, offer suggestions, etc. dm me. - E