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.

incrementing issue

Featured Replies

increment of bones collected (currently +=1; when clicking the ground item, clicks more than once sometimes so I need to figure out when the player collects the bone to inventory to increment then(any tips that'd be great!).

You could put a small pause after clicking/incrementing to insure only one click happens.

 

Also, for your counter, you can just do counterVariable++.

You don't need to do counterVariable += 1

  • Author

You could put a small pause after clicking/incrementing to insure only one click happens.

 

Also, for your counter, you can just do counterVariable++.

You don't need to do counterVariable += 1

 

I was aware of the ++ but was lazy way, anyways.

 

This is my function code for picking up bones, i'm picking them up in random tile locations so pin pointing a timer would be hard due to bones being further away, if it was simple as banking and burying then I wouldn't really have this issue what so ever; but because of random tile distances for the ground items Bones not sure if putting a timer is the right thing to do.

 

Maybe create an event per pickup, if the bone == null then ++ ? i'm not too sure exactly what code should be done to fix this sort of issue regarding my OP.

  • Author

I guess a good question to ask is:

Why are you incrementing the number of bones collected?

Well, it's just simply based on how many bones collected, if I had died it'd be less score than burried.

Honestly i'm a little tempted to remove it based on redundancy and to save time.

 

Side note to anyone who knows, does anyone know how to request a script for review to got to SDN? for future references I mean cause I still want to work and clean up before I give a request. Thanks!

So you simply want to know the number of bones collected during say, a 6 hour run period of your script?

Instead of incrementing on pickup, increment on bank deposit based on how many bones are in the inventory.

  • Author

So you simply want to know the number of bones collected during say, a 6 hour run period of your script?

Instead of incrementing on pickup, increment on bank deposit based on how many bones are in the inventory.

 

 

 

This is my function code for picking up bones, i'm picking them up in random tile locations so pin pointing a timer would be hard due to bones being further away

This script isn't utilizing the Banking option.

 

Function of script is according:

  1. Find local Bone (random tile based due to location demo (Chaos Temple))
  2. Pickup local bone
  3. Fill inventory
  4. Begin bury process
  5. Repeat

 

Side note: I got my goal of 43 prayer, thanks me! XD

You weren't clear in what the script was doing, which is why I asked.

All you need to do to start the burying process is check to see if the inventory is full. If it is, then begin burying. Once all the bones are buried, then drop any non-bone related items.

 

I'd show you how to do this, but it's been a few years since I've used the API. Also, you should be aware of how to do this if you're actively using the API. I know I used these necessary methods when I used the API, and they weren't that complex.

increment of bones collected (currently +=1; when clicking the ground item, clicks more than once sometimes so I need to figure out when the player collects the bone to inventory to increment then(any tips that'd be great!).

Easy solution would be recounting the bones in inventory and storing it to a int on every loop.

Or just use conditional sleeps:

int currentBonerCount = inventory.getItem("Bones").getAmount();

pickUpBone();

new ConditionalSleep(2_000) {
    @[member='Override']
    public boolean condition() throws InterruptedException {
        return inventory.getItem("Bones").getAmount() > currentBonerCount;
    }
}.sleep();

Edited by Hayase

  • Author

 

Or just use conditional sleeps:

int currentBonerCount = inventory.getItem("Bones").getAmount();

pickUpBone();

new ConditionalSleep(2_000) {
    @[member='Override']
    public boolean condition() throws InterruptedException {
        return inventory.getItem("Bones").getAmount() > currentBonerCount;
    }
}.sleep();

So this is my function for picking up

		case LOOTING_BONES:			
			if (!myPlayer().isAnimating()) {
				GroundItem bone = groundItems.closest("bones");
				if (bone != null) {
					bone.interact("Take");
					sleep(random(900));
					new ConditionalSleep(2_000) {
						@[member=Override]
					    public boolean condition() throws InterruptedException {
					        return inventory.getItem("bones").getAmount() > currentBonerCount;
					    }
					}.sleep();
				}
				
			}
			break;
g.drawString("Bones Collected: " + currentBonerCount, 5, 55);

Script doesn't startup

If you have trouble with picking up additional items, non-bone related, then I'd suggest implementing the counter after the inventory of bones is buried. What you'd do is bury the bones, count the empty spaces (and increment your counter), then drop all the non-bone items. This could be a better way, if written properly, to A) get an accurate bone count, and B) ensure you don't fill your inventory with non-bones which will cause the script to do nothing.

So this is my function for picking up

		case LOOTING_BONES:			
			if (!myPlayer().isAnimating()) {
				GroundItem bone = groundItems.closest("bones");
				if (bone != null) {
					bone.interact("Take");
					sleep(random(900));
					new ConditionalSleep(2_000) {
						@[member='Override']
					    public boolean condition() throws InterruptedException {
					        return inventory.getItem("bones").getAmount() > currentBonerCount;
					    }
					}.sleep();
				}
				
			}
			break;
g.drawString("Bones Collected: " + currentBonerCount, 5, 55);

Script doesn't startup

 

Pretty sure he's left a thing or two in there to break it, either intentionally so you can't just copy paste or unintentionally. Read through it logically and I'm sure you'll see it! I can see one at least smile.png

 

Also.. I'm not a scripter so don't take this 100% but why have you put a sleep, before a sleep?

Edited by HeyImJamie

Coming back to this issue I have a better idea if you want to try it.

 

Instead of taking count of the bones directly what about counting the empty spaces you have in your inventory and once you hit 0 you bury bones/bank and then restart?

//Somewhere up at the top of your script or wherever you are keeping track of your bone count:

int totalBones = 0;

case LOOTING_BONES:
    if (!myPlayer().isAnimating()) {
        GroundItem bone = groundItems.closest("bones");
        if (bone != null) {
            int currentFreeSpace = inventory.getEmptySlotCount();
            bone.interact("Take");

            /*
             * If you use conditional sleeps it will work more efficiently than static sleeping sleep(random(900));
             */
            new ConditionalSleep(900) {
                @[member='Override']
                public boolean condition() throws InterruptedException {
                    /*
                     * If our empty slot count is less than before--we must have picked up that bone
                     */
                    if (inventory.getEmptySlotCount() < currentFreeSpace) {
                        //Increase the bone count
                        totalBones++;
                        return true;
                    }
                    return false;
                }
            }.sleep();
        }
    }
    break;

Edited by Hayase

what? why are you counting freespace? This is all you need to do:

GroundItem foundBones = groundItems.closest("Bones");
if(foundBones != null) {
    long pastBones = inventory.getAmount("Bones");
    if(foundBones.interact("Take")) {
        new ConditionalSleep(5000) {
             @ Override
             public boolean condition() throws InterruptedException {
                      return inventory.getAmount("Bones") > pastBones;
             }
        }.sleep();
        if(inventory.getAmount("Bones") > pastBones) {
            bonesCollected++;
       }
    }
}

Edit: Also, please never use += 1.

Edited by Imateamcape

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.