Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Detecting change of an integer's value

Featured Replies

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

Store the value. And probably in your onLoop method you could do like...

if (newValue > oldValue)....

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

  • 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?

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

 

  • 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? 

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 by Okabe

  • 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

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

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.