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

Quick API calls shutdown sandbox without error

1460925428

Edited 1460925511
I have script function I am calling with an API textmessage from a roll button. As long as I do wait between clicks everything works fine but if quickly click the button twice it does shutdown my API sandbox and outputs without any error message. The script var handleSpellcastingCast = function(msg,character,spellname,id,force,basis,mod){ var castpool = basis + mod; var spell = characters.get("Zauber-"+spellname); if(spell==undefined){ whisperToGM(msg.who,msg.who," Zauber "+spellname+" nicht gefunden"); return; } var art = abilities.S(abilities.get(spell,"Art")); var category = abilities.S(abilities.get(spell,"Kategorie")); var range = abilities.S(abilities.get(spell,"Reichweite")); var damage = abilities.S(abilities.get(spell,"Schaden")); var duration = abilities.S(abilities.get(spell,"Dauer")); var drain = abilities.I(abilities.get(spell,"Entzug")); var description = abilities.S(abilities.get(spell,"Beschreibung")); // Unwrap the @{attribute} var drainattribute = attributes.I(attributes.unwrap(character,"tradition_drainattribute")); var drainmod = attributes.I(attributes.get(character,"tradition_drainmod")); var drainpool = drainattribute + drainmod; var myid = id; //Cast roll sendChat(character.get('name'), "/roll [["+castpool+"d6sacs5cs6>5kh"+force+"]]", function(x) { var RollValueCaster = x[0].inlinerolls[0]; var rollCast = buildInline(RollValueCaster, undefined, undefined); var successesCaster = parseInt(RollValueCaster["results"]["total"]); var totaldrain = Math.max(force + drain,2); sendChat(character.get('name'),"/roll [["+drainpool+"d6sacs5cs6>5]]",function(x) { var RollValueDrain = x[0].inlinerolls[0]; var rollDrain = buildInline(RollValueDrain, undefined, undefined); var successesDrain = parseInt(RollValueDrain["results"]["total"]); var draindamage = Math.max(totaldrain-successesDrain,0); whisperToGM(msg.who,msg.who,"&{template:zauber}"+ "{{text=zaubert "+spellname+"}}"+ "{{beschreibung="+description+"}}"+ "{{ks="+force+"}}"+ "{{basis="+basis+"}}"+ "{{mod="+mod+"}}"+ "{{pool="+castpool+"}}"+ "{{erfolge="+rollCast+"}}"+ "{{art="+art+"}}"+ "{{schaden="+damage+"}}"+ "{{kategorie="+category+"}}"+ "{{reichweite="+range+"}}"+ "{{entzug="+force+"+"+drain+"="+totaldrain+"}}"+ "{{entzugswiderstand="+totaldrain+"-"+rollDrain+"="+draindamage+"}}"+ "{{dauer="+duration+"}}"); }); }); }; The error message: Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was:
1460938207
Lithl
Pro
Sheet Author
API Scripter
That's clearly not the entirety of your script, since it's just a function definition and is calling functions that don't exist.
Clearly not. I did not expect someone to debug my script and therefore including the script in the first place was not clever from me. I wanted to report that the error message is missing - which should never happen. Also the timing of calls should not crash the API sandbox, it might be an error of a script if it uses timers, asynchronous calls (like mine) accessing the same variables (like character attributes) and in scenarios where we get into race conditions this can be the fault of the script. No matter what causes the error, the missing error message is a bug. The full script can be seen here, the function call hierarchy is&nbsp;registerEventHandlers-&gt;chat:message event-&gt;handleShadowrunInput-&gt;handleSpellcastingCast. <a href="https://gist.github.com/NoxMortem/fc50915412234ff8" rel="nofollow">https://gist.github.com/NoxMortem/fc50915412234ff8</a>...
1461009805
Phil B.
Forum Champion
Sheet Author
Which of your games are you using this script with? I'd like to give it a try myself and see if I can figure out what's going on.
1461010621

Edited 1461011020
Campaign 647721 How to reproduce: 1.) Open the Character "Basismensch" go to the character sheet 2.) Select main tab "Magie" 3.) Select sub tab "Spruchzauberei" 4.) In the first row with the title "Aufwecken" click the last button and confirm the popup with enter 5.) Quickly repeat 4. Two quick messages are sufficient to kill the sandbox. It depends on how quickly the second popup is shown. The script does read abilities from a character specified by a static prefix and the title (e.g. "Aufwecken"). It does neither create new attributes nor does it delete any. It does use multiple nested sendChat functions (roll for the player, roll for the spell, apply rule specific stuff based on those) The chrome dev console does not show any error. If the time between step 4 and 5 is sufficiently large nothing bad happens. Thank you very much Phil. I hope I can help finding the problem - and I hope it was not just me doing something stupid, but those errors of mine usually lead to very specific error messages :D
1461088386
Phil B.
Forum Champion
Sheet Author
I had to do some digging, but I figured out what the issue is. It's actually 2 separate issues, one causing the other. It's breaking when you submit the dialog really quickly, because you're submitting the dx before it has a chance to fill in the default value. This causes it to be submitted with no value. This, in turn, causes the message parser to end up with a NaN for one of the values that is then passed to sendChat with the roll query. The broken roll query is breaking sendChat's callback function, and the error is not properly being thrown back up to the top. So the 2 issues are:&nbsp;The default value should be filled in before the window is shown, and the broken roll query error should be handled better. I have passed this info off to Riley, our API guru, and he will look into fixing it when he has a few spare minutes.
Really, really cool! Thank you for investing the time for this! I will definetly have to improve the scripts, it's more like a very early pre-alpha version :D