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

Not getting eventInfo with a change event using Sheet Worker

1532830739

Edited 1532831020
I may be using the change event wrong.  I'm not getting the new or previous value when I change an attribute. on("change:temp_damage", function(eventInfo) { var diff = eventInfo.newValue - eventInfo.previousValue alert(diff); }
1532840468

Edited 1532840523
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
How are you initiating the attribute change? From a token's linked bars or directly on the sheet? Player caused change, or sheetworker caused change? Causing a token change from a linked bar does not pass the new/previousValue.
Directly from the sheet.  Doesn't matter if I increase the "temp_damage" value using spinners or directly changing on the attribute tab.
1532842329
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, ok, what's your HTML for this attribute, and what do you get if you log eventinfo?
I'm not sure how to check console in roll20.  I use "console.log" but don't see where it is. <div class="sheet-header">     <div class="sheet-section-name">Temp Damage</div>     <input type="number" name="attr_temp_damage" value = "0" min = "0"> </div>
1532866104
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, ok, HTML looks ok. The log output blends in with the rest of the console. Try putting something like console.log('=========================') before and after the log you are looking for to make it easier to see.
1532871924
GiGs
Pro
Sheet Author
API Scripter
Does alert work in sheet workers? Try replacing that with console.log as Scott suggests. Typing F12 or rightclicking anything on a character sheet and Inspect Element should let you access the log. Do you have any other sheet workers in the sheet, and are they working fine? Sometimes a break in one script, if it's big enough, can stop all of them working. Is your script in a properly formed script block?
1532872379
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Oh, something that just occurred to Michael, attribute values are almost ways strings (it is always when entered by a player). Change your formula to make sure it is actually converting them to numbers: (eventInfo.newValue*1||0) - (eventInfo.previousValue*1||0)
1532874977
Jakob
Sheet Author
API Scripter
There's a syntax error, missing closing brace.
1532876344
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Jakob said: There's a syntax error, missing closing brace. Heh, always the little things. Also, I'll recommend the Google closure compiler for easily finding things like this.
Doh!  Sorry for that guys.  It works now but it takes a really long time to see the effect.  Like literally 5 seconds after changing the attribute before it updates the other one.  Here is the log: Really updating character sheet values app.js?1532449094:351 Setting up repeating sections took until 1ms app.js?1532449094:351 Finding list of dirty attributes took until 1ms app.js?1532449094:351 Querytest took until 1ms VM16:5 ========================= app.js?1532449094:351 Attribute cache compliation took until 2ms app.js?1532449094:352 Set values (including auto-calcuating variables) took until 2ms app.js?1532449094:352 Took 3ms app.js?1532449094:351 Really updating character sheet values app.js?1532449094:351 Setting up repeating sections took until 1ms app.js?1532449094:351 Finding list of dirty attributes took until 1ms app.js?1532449094:351 Querytest took until 1ms app.js?1532449094:351 Attribute cache compliation took until 2ms app.js?1532449094:352 Set values (including auto-calcuating variables) took until 2ms app.js?1532449094:352 Took 3ms
1532879803
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Well, your code that you posted won't actually cause an effect on the sheet.
Nevermind!  Apparently on change doesn't fire until you change focus.
It looks like "on click" doesn't work either.  Is there any way to have it update on mouseup?
1532882162
GiGs
Pro
Sheet Author
API Scripter
You have to change focus, so tabbing out of the field works or clicking pretty much anywhere else as long as the mouse focus changes.
yeah and it looks like none of the other js events work like onclick or mouseup.  kind of a bummer
1532883093
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
you can only use onclick with the action buttons that were introduced.
Thanks!  Is there a wiki for them?  Are those the API command buttons?
1532976562
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I don't think they've made it into the wiki yet. they were introduced in the latest update for character sheets. Can't find the original post, but GG quoted the relevant sections here:&nbsp; <a href="https://app.roll20.net/forum/post/6527829/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/6527829/slug%7D</a> They were released with the charactermancer update.
Wow that’s pretty cool. And easy enough to change &nbsp; although I’d probably have to change the input from number to text and add an up and down button instead of spinners &nbsp;