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 .
×

[API Script] Script Error for Pathfinder2e Game but works with CoC and PF1e

Hello, &nbsp; &nbsp; I'm trying to trouble shoot the following script which fails when used in a Pathfinder2e setting, but works in Call of Cthuhlu and the Pathfinder1e setting. The documentation is missing pathfinder 2e explicit coding samples for the following handout.&nbsp; (These scripts were generated by code I created to import the contents into VTTs.) API Javascript Code for handout generation: var SecondEditionScenario802TheFey ReclamationLevels34ByLucasServ ideo0 = createObj('handout', { name: 'Second Edition Scenario #8 -02 The Fey Reclamation Levels 3–4 By Lucas Servideo', inplayerjournals: '', archived: false }); SecondEditionScenario802TheFey ReclamationLevels34ByLucasServ ideo0.set({ notes: '', gmnotes: '&lt;h2&gt;Second Edition Scenario #8 -02 The Fey Reclamation Levels 3–4 By Lucas Servideo&lt;/h2&gt; &lt;p&gt;AUTHOR&lt;/p&gt; &lt;p&gt;Lucas Servideo&lt;/p&gt; &lt;p&gt;DEVELOPMENT LEAD&lt;/p&gt; &lt;p&gt;Josh Foster&lt;/p&gt; &lt;p&gt;EDITING LEAD&lt;/p&gt; &lt;p&gt;Solomon St. John&lt;/p&gt; &lt;p&gt;EDITOR&lt;/p&gt; &lt;p&gt;Avi Kool&lt;/p&gt; &lt;p&gt;COVER ARTIST&lt;/p&gt; &lt;p&gt;Felipe Fornitani and Arthur Henrique Olivera Silva&lt;/p&gt; &lt;p&gt;INTERIOR ARTISTS&lt;/p&gt; &lt;p&gt;Sergio Cosmai, Riccardo Moscatello, and Arthur Henrique Olivera Silva&lt;/p&gt; &lt;p&gt;CARTOGRAPHERS&lt;/p&gt; &lt;p&gt;Jason Engle and Matthias Rothenaicher&lt;/p&gt; &lt;p&gt;ART DIRECTION AND GRAPHIC DESIGN&lt;/p&gt; &lt;p&gt;Emily Crowell&lt;/p&gt; &lt;p&gt;ORGANIZED PLAY MANAGER&lt;/p&gt; &lt;p&gt;Alex Speidel&lt;/p&gt; &lt;p&gt;CREATIVE DIRECTOR&lt;/p&gt; &lt;p&gt;James Jacobs&lt;/p&gt; &lt;p&gt;ASSOCIATE PUBLISHER&lt;/p&gt; &lt;p&gt;Thurston Hillman&lt;/p&gt; &lt;p&gt;PUBLISHER&lt;/p&gt; &lt;p&gt;Erik Mona&lt;/p&gt; &lt;p&gt;The Fey ReclamationThe Fey Reclamation&lt;/p&gt; &lt;p&gt;Table of Contents&lt;/p&gt; &lt;p&gt;Adventure . . . . . . . . . . . . . . . . . . . . . . . . . . 3&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Appendix:&lt;/strong&gt; Statistics . . . . . . . . . . . . . . . . . . . . 12&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Appendix:&lt;/strong&gt; Game Aids . . . . . . . . . . . . . . . . . . . .13&lt;/p&gt; &lt;p&gt;Organized Play . . . . . . . . . . . . . . . . . . . . . . .14&lt;/p&gt; &lt;p&gt;GM Resources&lt;/p&gt; &lt;p&gt;Campaign Home Page: pathfindersociety.club&lt;/p&gt; &lt;p&gt;Books: Pathfinder Player Core, Pathfinder Player Core 2, Pathfinder GM Core, Pathfinder Monster Core, Pathfinder Monster Core 2&lt;/p&gt; &lt;p&gt;Maps: Pathfinder Flip-Mat: Fungal Forest&lt;/p&gt; &lt;p&gt;Online Resource: Pathfinder Reference Document at paizo.com/prd &lt;/p&gt; &lt;p&gt;Scenario Tags&lt;/p&gt; &lt;p&gt;Scenario tags provide additional information about an adventure’s contents. For more information on scenario tags, see the Guide to Organized Play: Pathfinder Society at <a href="https://lorespire.paizo.com/" rel="nofollow">https://lorespire.paizo.com/</a>.&lt; /p &gt; &lt;p&gt;Level and Difficulty&lt;/p&gt; &lt;p&gt;This scenario can be played by characters of 3rd or 4th level. The encounters in this scenario are designed for a group of six characters of 3rd level. You can use the Adjusting Difficulty sidebars to make the adventure easier or harder, to accommodate groups of various sizes and levels.&lt;/p&gt; &lt;p&gt;Summary&lt;/p&gt; &lt;p&gt;An enigmatic fey monarch has laid claim to the nation of Bhopan and demands that the Pathfinders perform a task in return for relinquishing the claim. The PCs face inscrutable fey requests and troublesome fey rivals, all to secure a nation’s freedom.&lt;/p&gt; &lt;p&gt;HOW TO PLAY&lt;/p&gt; &lt;p&gt;PLAY TIME: 2–3 HOURS&lt;/p&gt; &lt;p&gt;LEVEL: 3–4&lt;/p&gt; &lt;p&gt;PLAYERS: 3–6&lt;/p&gt; &lt;p&gt;Paizo Inc.&lt;/p&gt; &lt;p&gt;15902 Woodinville-Redmond Rd NE, Unit B&lt;/p&gt; &lt;p&gt;Woodinville, WA 98072-4572&lt;/p&gt; &lt;p&gt; paizo.com &lt;/p&gt;' }); Error: For reference, the error message generated was: file:///home/node/d20-api- server/api.js:1855 list = Object.keys(Roll20Classes). filter( ^ TypeError: Cannot convert undefined or null to object at Object.keys (&lt;anonymous&gt;) at GetValidCreateClasses (file:///home/node/d20-api- server/api.js:1855:19) at getValidCreateClasses (file:///home/node/d20-api- server/api.js:1869:32) at createObj (file:///home/node/d20-api- server/src/createObj.js:46:91) at createObj (file:///home/node/d20-api- server/api.js:2136:24) at SCRIPT: Handout.js [Tab 3]:1:153 at Script.runInContext (node:vm:149:12) at Script.runInNewContext (node:vm:154:17) at Object.runInNewContext (node:vm:310:38) at file:///home/node/d20-api- server/api.js:2407:38 Here are screen shots of the handouts in a CoC and PF1e Games ... I was told post here, twice. Thanks for any help with this.
I figured out the solution.&nbsp; &nbsp; Drop Down box on the API Page needs to be changed from Experimental to Default.
1787864537
The Aaron
Roll20 Production Team
API Scripter
I'll see about preventing that crash. The issue is that the createObj() call is happening before the object hierarchy exists, causing it to fail when it tried to find the type 'handout'.&nbsp; One fix on your end is to wrap the code in on('ready',...) to let the whole Mod Script Sandbox to load before you start adding objects. That's best practice in general, early action is a bit dangerous, particularly creating objects. =D
1788034140
The Aaron
Roll20 Production Team
API Scripter
I've got the fix for this in QA now.&nbsp; Should be out next week.
1788198993
The Aaron
Roll20 Production Team
API Scripter
This fix is deployed now, thanks for bringing it up!&nbsp; Definitely let me know if you run into any other issues.
1788213181

Edited 1788215505
I will, thank you for doing that! Downside, I'm no longer incentivized to update my code that generates the script :(&nbsp; I'll try to get to it now ... you are awesome! (edit - fix punctuations, got excited about the change!)