January 5, 201610 yr 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!
January 5, 201610 yr Store the value. And probably in your onLoop method you could do like... if (newValue > oldValue)....
January 5, 201610 yr 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
January 5, 201610 yr Author 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?
January 5, 201610 yr 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
January 5, 201610 yr Author 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?
January 5, 201610 yr 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, 201610 yr by Okabe
January 5, 201610 yr Author 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
January 5, 201610 yr 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, 201610 yr by Joseph
Create an account or sign in to comment