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.

how to place a sleep when smelting?

Featured Replies

i'm trying to smelt gold amulets for free crafting exp but the script will not sleep when smelting

here is the portion so far

i know 10 seconds isn't enough to craft 27 amulets but it's relooping after like 2 amulets which is like 4 seconds

case MAKEAMULETS:
			getWalking().webWalk(new Position[] {furnaceposition});
			if(getWidgets().isVisible(446, 32))
			{
				getWidgets().interact(446,32,"Make-X");
				sleep(random(300,500));
				if(getWidgets().isVisible(162, 33))
				{
					getKeyboard().typeString("27", true);
				}
				new ConditionalSleep(10000)
	            {					
					@Override
					public boolean condition() throws InterruptedException 
					{
						return !myPlayer().isAnimating();
					}
				}.sleep();
			}
			else
			{
				Entity furnace = objects.closest("Furnace");
				getInventory().interact("Use", "Gold bar");
				sleep(random(200,300));
				furnace.interact("Use");
			}
			break;

Edited by justanotherkid

while(myPlayer().isAnimating())
{
     sleep(500);
}

should work, idk if its clean though

 

with ur conditional sleep it will wait for the remaining of the 10seconds if you're done smelting

Edited by The Hero of Time

  • Author
while(myPlayer().isAnimating())
{
     sleep(500);
}

should work, idk if its clean though

 

with ur conditional sleep it will wait for the remaining of the 10seconds if you're done smelting

 

no, that didn't work either but there is a workaround i used to

 

return !getInventory().contains("gold bars") || getDialogue().inDialogue(); // the dialogue part is for when it levels up crafting

Edited by justanotherkid

no, that didn't work either but there is a workaround i used to

 

return !getInventory().contains("gold bars") || getDialogue().inDialogue(); // the dialogue part is for when it levels up crafting

when im cooking fish, i use the while loop to check if i still have raw fish.  when it levels up  i check on the level-up widget, not indialoge, but i guess it both works

The character only animates when it's placing the ore in the furnace, therefore it will only wait for a very short period before interacting with the furnace again.

EDIT: The following eliminates the issue of sleeping while proceeding with an action, as well as eliminating the issue of animations occurring only for a short period of time.

 

When crafting you expect an experience gain every few seconds, let's use this to build a predetermined time in the future which we can check our previous crafting experience with our current crafting experience.

 

We simply cache our crafting experience every 'check' before we are going to gain any new experience, every check, we get the current system time and add 4 - 6 seconds (the timeout essentially) to get our time for the next 'check'.

 

In pseudo code the following would be it's own method:


IF bar count = 0 THEN
RETURN false
END IF

IF CurrentTime > LastCheckedTime + timeout THEN
   IF CurrentCraftingXP > PreviousCraftingXP THEN
    PreviousCraftingXP = CurrentCraftingXP 
    LastCheckedTime = CurrentTime
   
    RETURN TRUE
    
    ELSE
    
    RETURN FALSE
    END IF
ELSE
RETURN TRUE
END IF

Edited by Final

while(myPlayer().isAnimating())
{
     sleep(500);
}

should work, idk if its clean though

 

with ur conditional sleep it will wait for the remaining of the 10seconds if you're done smelting

 

That will not work for his purpose.

while(getInventory().contains("Gold bar")
{
    sleep(500);
}

Nope.

 

If you really want to use a while loop, always have a backup so it doesn't get stuck in the loop.

while(getInventory().contains("Gold bar")
{
    sleep(500);
}

 

I wouldn't use this. Just because the user has a gold bar doesn't mean that he's smelting, something such as a level up or unwanted interaction could disrupt this, furthermore it's a while loop and there's clear reasons of why not to use a while loop within a script (a while loop).

I wouldn't use this. Just because the user has a gold bar doesn't mean that he's smelting, something such as a level up or unwanted interaction could disrupt this, furthermore it's a while loop and there's clear reasons of why not to use a while loop within a script (a while loop).

Why r u stalking me?

Nope.

 

If you really want to use a while loop, always have a backup so it doesn't get stuck in the loop.

obviously, but OP already has that as far as i know, he already has the logic for leveling up

 

 

 

@op this is how i have it

0ac9787689.png

Edited by The Hero of Time

obviously, but OP already has that as far as i know, he already has the logic for leveling up

 

 

 

@op this is how i have it

0ac9787689.png

You are making the same mistake for using while loop. You shouldn't use a while loop for sleeping purpose.

Edited by Woody

 

i'm trying to smelt gold amulets for free crafting exp but the script will not sleep when smelting

here is the portion so far

i know 10 seconds isn't enough to craft 27 amulets but it's relooping after like 2 amulets which is like 4 seconds

case MAKEAMULETS:
			getWalking().webWalk(new Position[] {furnaceposition});
			if(getWidgets().isVisible(446, 32))
			{
				getWidgets().interact(446,32,"Make-X");
				sleep(random(300,500));
				if(getWidgets().isVisible(162, 33))
				{
					getKeyboard().typeString("27", true);
				}
				new ConditionalSleep(10000)
	            {					
					@Override
					public boolean condition() throws InterruptedException 
					{
						return !myPlayer().isAnimating();
					}
				}.sleep();
			}
			else
			{
				Entity furnace = objects.closest("Furnace");
				getInventory().interact("Use", "Gold bar");
				sleep(random(200,300));
				furnace.interact("Use");
			}
			break;

 

 

Easiest way imo is just to do a long sleep, and check if you still have gold bars / have leveled up:

if(getKeyboard().typeString("27")){
    new ConditionalSleep(100_000){					
        @Override
        public boolean condition() throws InterruptedException {
            return !getInventory().contains("Gold bar") || getDialouges().isPendingContinuation();
        }
    }.sleep();
}

Edited by Explv

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.