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] Linking Attributes to Markers - throwing an infinite loop / long running process???

<a href="https://gist.github.com/anonymous/71497247529acb1d" rel="nofollow">https://gist.github.com/anonymous/71497247529acb1d</a>...
1404132890
The Aaron
Roll20 Production Team
API Scripter
It's hard to respond to this without some background. Is this a script you wrote, or one someone else did? Has it been working but just started failing? Did you modify part of it recently? Does it fail immediately, or is there a sequence of events that causes the failure?
Someone else did, all I did was add more markers to the list (at the top). It worked at first when I tested it, but now it pretty much always just throws the long running process / infinite loop error. The error is thrown immediately. My only guess is that I have added too many markers to the list. My next plan is to cut back on the number and retest.
I mean, you're calling a function to update the statusmarkers, inside of an event callback that happens whenever a statusmarker changes. How would that not cause an infinite loop? on('change:graphic:statusmarkers', function(obj, prev) { .. updateAllTokens(charId, opts.marker, markerValue); //which changes the statusmarkers of a bunch of tokens...
1404137878
The Aaron
Roll20 Production Team
API Scripter
For some reason, I was thinking that the only events you could trigger from the API were "chat:message" events via sendChat()? I guess that's not the case?
Riley D. said: I mean, you're calling a function to update the statusmarkers, inside of an event callback that happens whenever a statusmarker changes. How would that not cause an infinite loop? on('change:graphic:statusmarkers', function(obj, prev) { .. updateAllTokens(charId, opts.marker, markerValue); //which changes the statusmarkers of a bunch of tokens... Wouldn't it only call it once for each marker? I got it here : <a href="https://app.roll20.net/forum/post/746846/script-li" rel="nofollow">https://app.roll20.net/forum/post/746846/script-li</a>... It seems to work for him???
1404172060

Edited 1404172121
Lithl
Pro
Sheet Author
API Scripter
Aaron said: For some reason, I was thinking that the only events you could trigger from the API were "chat:message" events via sendChat()? I guess that's not the case? What Aaron said. It has been my experience that changing an object's properties will not fire events, for exactly this reason. sendChat will fire chat:message events, but obj.set will not fire property changed events. It seems more likely that this is the rarely-explicable long-running process issue cropping up again.
1404172211
The Aaron
Roll20 Production Team
API Scripter
Should be easy enough to test... be right back.. =D
1404173424
The Aaron
Roll20 Production Team
API Scripter
Ok. Testing complete. I can't get an infinite loop with this. Test Script: on('ready', function(){ log('setting up status marker script'); on('change:graphic:statusmarkers', function(obj, prev) { if(obj.get('status_red')) { log('red is set!') var red=obj.get('status_red'); var count=parseInt( red === true ? 0 : red )+1; log('red count is at: '+count); if( count &lt; 10) { log('setting red to '+count) obj.set('status_red',count); } else { log('no more updating!') } } }); }); Log Results: "setting up status marker script" "red is set!" "red count is at: 1" "setting red to 1"
Which is what I expected. If I have to click a macro button every time a marker changes it would defeat the entire purpose of the script sadly.
1404243083
The Aaron
Roll20 Production Team
API Scripter
I'm just saying, I don't think your infinite loop is a result of the script setting status updates during status updates. I'll try to run your script on one of my own campaigns and see if I can figure out what's going on. If I can't get the infinite loop on mine campaign, I'll see about joining yours and debugging it in situ.