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 here.
×
×
Cookie Preferences
We use Cookies to help personalize and improve Roll20. For more information on our use of non-essential Cookies, visit our Privacy Policy here.
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);
}
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.
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>
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.
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?
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)
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
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: <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 although I’d probably have to change the input from number to text and add an up and down button instead of spinners