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)
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. https://closure-compiler.appspot.com/home
Awesome, that's exactly what I needed! Thank you so much! There were two quotation marks that were wrong. 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?
.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 github or using 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.