Jump to content

incrementing issue


Booleans YAY

Recommended Posts

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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