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

[Script] Wild Magic Surge API help

I have a custom Wild Magic surge table for a campaign I'm running and I was looking for a way to integrate it into r20. I stumbled upon  this thread in which  Pyromanci made a surge API for the "Net Libram of Random Magical Effects". I copied pyromanci's API to test it and it worked great, so I went through and tried to alter it to my table. I know pretty much nothing about coding, so unsurprisingly it is coming up with an error that says the following: SyntaxError: Unexpected token ,  That said, the only changes I made besides the effects text was reducing the table down to 600 from 10,000 and changing one line near the end of the script  from var roll = randomInteger(10000);  to var roll = randomInteger(600); Besides that, I've gone through and made sure all of the formatting is identical. Though I'm more than willing to accept that I'm futzing with super complicated stuff I have no real means of understanding, I figured I may just be missing something simple. Any ideas?  (I would post my version of the code, but I'm not really sure how to do that : p)
1487338949
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It sounds like you're missing a variable declaration or an ending comma/semicolon. I'd recommend loading it into the Google closure compiler which will give a much more detailed explanation of the problem. <a href="https://closure-compiler.appspot.com/home" rel="nofollow">https://closure-compiler.appspot.com/home</a>
1487350264

Edited 1487350402
Bear
Pro
Awesome, that's exactly what I needed! Thank you so much! There were two quotation marks that were wrong.&nbsp; Unfortunately, now it's having the problem where the effect is coming out undefined, like so: Ursa (GM): Surge Roll 452 Effect: undefined The closure compiler shows two warnings, but only when run with advanced optimization, as follows: Number of warnings: 2 JSC_POSSIBLE_INEXISTENT_PROPERTY: Property who never defined on msg at line 654 character 15 sendChat(msg.who, "/direct " + makeSurge()); ^ JSC_POSSIBLE_INEXISTENT_PROPERTY: Property who never defined on msg at line 658 character 15 sendChat(msg.who, "/w gm " + makeSurge()); ^ Those warnings also show up when I run the original Net Libram script version through advanced optimization, but that API works fine still. Any thoughts?
1487350731

Edited 1487351286
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
.who is a property that is part of the message object that is passed to the API from the chat parser. You never define it, it just is part of the object. You'll need to provide the code for any further help. I recommend making a gist on&nbsp; github or using&nbsp; pastebin to create a shareable text file. EDIT: I would however guess that makeSurge is not returning the effect. That is only based on the two sendChat lines that you show in those warnings though, so take it with a grain of salt.