Ace Posted January 5, 2016 Share Posted January 5, 2016 Hey, I'm trying to figuring out how I could best detect the change of an integer's value. In the GWD there are widgets for the current kill count and what I'm trying to do is parse the message of the widget to an integer and then detect when this integer increases so you can get a pretty accurate kill counter. Do you guys have any ideas of how to detect if an integer has increased in its value? Any help is greatly appreciated! Quote Link to comment Share on other sites More sharing options...
KEVzilla Posted January 5, 2016 Share Posted January 5, 2016 Store the value. And probably in your onLoop method you could do like... if (newValue > oldValue).... Quote Link to comment Share on other sites More sharing options...
FrostBug Posted January 5, 2016 Share Posted January 5, 2016 It's probably not gonna be easy to have it do a callback to some listener; so your only options are something to have asynchronous checks on the value, or just check it in onloop as kevzilla suggested Quote Link to comment Share on other sites More sharing options...
Ace Posted January 5, 2016 Author Share Posted January 5, 2016 It's probably not gonna be easy to have it do a callback to some listener; so your only options are something to have asynchronous checks on the value, or just check it in onloop as kevzilla suggested Alright, I've already tried what kevzilla suggested and I think I'm thinking too far. So the current kill count is always the widget text and how would I define the old/new one so I can compare them? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted January 5, 2016 Share Posted January 5, 2016 Alright, I've already tried what kevzilla suggested and I think I'm thinking too far. So the current kill count is always the widget text and how would I define the old/new one so I can compare them? uh.. you define the old one the same was as you would the new one. You only really need one variable Alternatively, it might be possible to do it async using a config listener 1 Quote Link to comment Share on other sites More sharing options...
Ace Posted January 5, 2016 Author Share Posted January 5, 2016 uh.. you define the old one the same was as you would the new one. You only really need one variable Alternatively, it might be possible to do it async using a config listener and would I compare them onLoop? wouldn't then the values always be the same? Quote Link to comment Share on other sites More sharing options...
Okabe Posted January 5, 2016 Share Posted January 5, 2016 (edited) and would I compare them onLoop? wouldn't then the values always be the same? Yes in the onLoop or a thread. no since you compare the values before you move the current value into the class variable. Edited January 5, 2016 by Okabe 1 Quote Link to comment Share on other sites More sharing options...
Ace Posted January 5, 2016 Author Share Posted January 5, 2016 Yes in the onLoop or a thread. no since you compare the values before you move the current value into the class variable. okay I got it working so that it counts correctly but the thing is that the counter starts not at 0 but at the number that the widget is showing. So for example: You start the script and in GWD you already have 50 kill count, so the script starts to count at 50 instead of 0. And once you leave the GWD the kill count will be reset Quote Link to comment Share on other sites More sharing options...
Joseph Posted January 5, 2016 Share Posted January 5, 2016 (edited) use 2 variables startAmount, currentAmount. state the startAmount when you start. currentAmount should be what you have now then to get the right amount of stuff do. Real amount - currentAmount - startAmount = real amount tracked Edited January 5, 2016 by Joseph 2 Quote Link to comment Share on other sites More sharing options...