Jump to content

Detecting change of an integer's value


Recommended Posts

Posted

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! :)

Posted

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?

Posted

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

 

  • Like 1
Posted

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? 

Posted

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

Posted (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 by Joseph
  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...