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

eventInfo previous and new value broken (again)

1743840827
StéphaneD
Pro
Sheet Author
API Scripter
Hi Looks like for some reason, eventInfo does not send me the data I need in my sheetworker Context : - Legacy sheet (not Beacon) - Legacy environment (not Jumpgate) - Changing an attribute value from the sheet (not from a token bar linked to the attribute) This is the HTML : <div class="bordered centered"> <input type="number" class="two-digits" name="attr_pv" title="@{pv} PV courants" value="0"> / <input type="number" class="two-digits" name="attr_pv_max" title="@{pv_max} PV maximum" value="0"> </div> This is the sheet-worker : /**  * Change current resource when max resource changes  */ on("change:pv_max change:dr_max change:pm_max change:pc_max", function(eventInfo) {   const resource = eventInfo.sourceAttribute.split("_")[0];   const changed = intval(eventInfo.newValue) - intval(eventInfo.previousValue);   console.log(eventInfo);    return;   getAttrs([ resource ], function(values) {     const curValue = intval(values[resource]);     setAttrs({ [resource]: curValue + changed });   }); }); This is the eventInfo object that comes in when I change the pv_max value on the sheet : {     "sourceAttribute": "pv_max",     "sourceType": "player",     "triggerName": "pv_max" } Any one else seeing this as well ? TIA
1743854496
vÍnce
Pro
Sheet Author
I recall that being brought up on the forums as a bug a few years ago..  Not sure if it was ever rectified.  I'll see if I can locate the posts.
1743854843
vÍnce
Pro
Sheet Author
Bug report with eventInfo First time the value is changed, previousValue and newValue are the same
1743862543

Edited 1743863214
StéphaneD
Pro
Sheet Author
API Scripter
Hi vince Thanks Well you can say that the previous and new values are the same now since they’re both undefined ;-) Unfortunately they never show up, whatever number of times the value is changed… Wonder if GiGs ever got an answer ? Maybe I should open an issue on the R20 ticket system ?
1743878588
GiGs
Pro
Sheet Author
API Scripter
I never received an official statement about this. If I understand your issue, I did post a work around in that thread. If the change event has been triggered, a change MUST have occurred, os if you test for prevValue and newValue, and they are both same, you know this is the first change. If they never show up, that is another issue - butif they both ever show up, that is also information and this is probably the only time it will happen.
1743879204
StéphaneD
Pro
Sheet Author
API Scripter
Hi GiGs It must be another issue as these two properties of the eventInfo object never show up Thanks all. I’ll try a ticket on Roll20 support.
1743907280
GiGs
Pro
Sheet Author
API Scripter
Are you sure the sheet worker is being triggered? Just asking to eliminate that possibility, good luck with roll20 support.
1743913688
StéphaneD
Pro
Sheet Author
API Scripter
Yes, it is triggered as I have the console.log() that I have pasted in my first post above. The eventInfo tells me that the pv_max attribute was changed by the player, which it was. But it does not tell me the previous and new values. 
1743977336
GiGs
Pro
Sheet Author
API Scripter
It seems like you might be able to use that (as a work around). If the sheet worker tries to get the new/prevvalues and gets nothing, you know something has triggered the worker under the situation that gives no info. If you use getAttrs, do you get the attribute value?
1744006909
StéphaneD
Pro
Sheet Author
API Scripter
GiGs Thanks but you're missing the point.  getAttrs() will give me the current value, but that's not enough for what I want to do. What I am trying to achieve is that if the 'pv_max' value has changed from 10 to 15, I want to add 5 to 'pv' current value. If you know a way of doing that without the previousValue and newValue, then let me know. But I don't think it is possible. And anyway it's in the doc. So if it's not in the object anymore, either the doc must be amended, or the bug must be corrected. And it seems that it is even more screwed up than that. The sheetworker above listens for the 'pv_max' value changes, but it is also triggered when the 'pv' value changes. But no previousValue and newValue in either case.  However I just tested with another attribute that is not an attribute that has a current and max value, and I do get these properties. So I think it is a bug, but it is limited to _max attribute
1744027690
GiGs
Pro
Sheet Author
API Scripter
I wasn't so much as missing the point as trying to find the extent of this bug. You're right, it definitely sounds like a bug. One thing i always encourage: if a single character sheet is not acting as it should, create a new character and see if the behavior remains. During design, lots of changes on a single sheet can cause that sheet to become corrupt.
1744028237
StéphaneD
Pro
Sheet Author
API Scripter
I remembered using these properties on older sheets I have developed and so I did some additional testing, and it worked as expected. Then I noticed that I had used these properties on regular attributes, not attributes with max values. So I added a log of eventInfo on another regular attribute of the new sheet, and it worked as well. I have opened a support ticket. With all that has happened lately in Roll20 and the focus on newer stuff, I doubt I'll have any answer soon, but one can always hope...