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

MagicalSurge.js fix needed

Ok, so this is more about Github than about the API.&nbsp; I don't know how to use GitHub... or at least I don't know why it's not letting me do a "pull" so I can fix the broken code. I'm trying to fix the MagicalSurges.js script in the Github repository at: <a href="https://github.com/nmrcarroll/MagicalSurges/blob/master/MagicalSurges.js" rel="nofollow">https://github.com/nmrcarroll/MagicalSurges/blob/master/MagicalSurges.js</a> What is needed is to make the following change: &nbsp; &nbsp; if (!cantrip &amp;&amp; (spell_level &gt; 0 || msg.rolltemplate == 'spell')) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const roll = randomInteger(20); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!cantrip &amp;&amp; (spell_level &gt; 0 || msg.rolltemplate == 'spell')) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let chatMesg = ''; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chatMesg = `&amp;{template:simple} {{rname=Wild}} {{r1=${roll}}} {{normal=1}}`; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (whisper == undefined) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat(msg.who, chatMesg); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat(msg.who, `/w gm ${chatMesg}`); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat(msg.who, `/w ${msg.who} ${chatMesg}`); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return roll; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; }, The problem is that the script, as written, was always returning a 0 when exiting from Checkspell() so that the code later on: handleInput = function (msg) { &nbsp; &nbsp; &nbsp; const spellRollTemplates = [ 'spell' , 'atk' , 'dmg' , 'atkdmg' ]; &nbsp; &nbsp; &nbsp; if (msg. type !== 'api' ) { &nbsp; &nbsp; &nbsp; &nbsp; if (msg &amp;&amp; msg. rolltemplate &amp;&amp; spellRollTemplates. includes (msg. rolltemplate )) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const roll = checkSpell (msg); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const whisper = msg. target ; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (roll == 1 ) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const mSurge = makeSurge (); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (whisper == undefined) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat (msg. who , mSurge); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat (msg. who , `/w gm ${mSurge} ` ); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat (msg. who , `/w ${msg. who } ${mSurge} ` ); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return roll; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; } where roll is tested, always failed and so makeSurge() was never called.&nbsp; By putting the return in the above code, the value of "roll" was returned so the test would succeed when a 1 was rolled in the Checkspell() function. However, since I don't know how to get a pull request done on Github, I can't update the script with the fix.&nbsp; If someone can do this, or tell me how, I'd appreciate it.&nbsp; I've tested the new code and it works so I think the fix is correct. Thank you.
1592746010
timmaugh
Forum Champion
API Scripter
So, the GitHub terminology can be a bit strange. You need to make your change and make a "Pull Request"... here's the short version Install the GitHub Desktop app and clone the R20 API Repository. It will sync everything to your computer. Make your changes locally (on the version that copied to your desktop), or copy in your altered file from your work area. "Push" your changes to the origin, which copies your files up to your clone of the R20 repository. Go to your GitHub Repository (on GitHub), and create a "Pull Request". That will tell R20 (the people with "write" rights to the master branch of the GitHub repository) that there is an update here waiting to be merged in. Every week, starting around Monday, the R20 team revues these Pull Requests to make sure they won't cause a problem, and then merge them in. If there is a problem (probably won't apply to what you want to do), then they leave a comment to let you know what to fix. Then, that's it. Your update is applied. So... Download app... clone... change... Push... create Pull Request... enjoy a drink. ;-)
1592746071
timmaugh
Forum Champion
API Scripter
If I didn't make it clear, you have to create the Pull Request from your branch/repository, not the master R20 repository. You don't have rights, there.
1592748545

Edited 1592748583
GiGs
Pro
Sheet Author
API Scripter
If you're using github desktop, here's a setp by step I posted this week:&nbsp; <a href="https://app.roll20.net/forum/permalink/8845549/" rel="nofollow">https://app.roll20.net/forum/permalink/8845549/</a> It's for the character sheet forum, so you can ignore the first part, but the 10 steps are good.