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.

Looking for feedback on my script

Featured Replies

Anyways, made a quick alching script, just putting here if anyone has any comments on how to make it more efficient/smaller and tips on something to improve in coding if there is.

 @Override
    public int onLoop() throws InterruptedException
    
    	{
    		switch (state)
    	{
    	
    	case INIT:
    		if (getMagic().canCast(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY ));
    			state = State.ALCH;
    				break;
    	
    	case ALCH:
    		if (inventory.contains("Maple longbow (u)"));
    			state = State.ALCH2;
    		
    	case ALCH2:
    		getMagic().castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY);
    			sleep(random(350, 455));
    				state = State.ALCH3;
    					break;
    		
    	case ALCH3:
    		if (getMagic().isSpellSelected())
    			{
    				getInventory().interactWithNameThatContains("Cast", "Maple longbow");
    					sleep(random(1250, 1700)); 
    						state = State.ALCH; }
    							break;
    			
    			
    	}   		
        return random(200, 300);
    }

A valiant effort!

 

A few things. The structure is acceptable but a little scrambled. You'd be better off just using if loops instead of playing around with enumerated state frameworks for such a simple activity.

 

Secondly, it would be a good idea to put the string of the item you're interacting with as a variable at the top of your code so you can adjust it as a parameter in one place.

 

Finally, i'd recommend instead of using static sleep durations such as sleep(random(x,y));, you use conditional sleeps which wait until the magic tab /inventory / spell selected or whatever to determine what stage of the alch you are in. If it makes you feel more comfortable, you can add very small delays in-between, but I think the tick rate and network speed will account for atleast some randomness anyway.

 

Other than that, looks like it gets the job done, and congrats on writing your first script! Pretty good!

 

the next step is maybe a gui and/or paint! :)

 

~apa


PS i'm a pretty tired out so sorry if something I said didn't make sense, too tired to proof read

  • Author

A valiant effort!

 

A few things. The structure is acceptable but a little scrambled. You'd be better off just using if loops instead of playing around with enumerated state frameworks for such a simple activity.

 

Secondly, it would be a good idea to put the string of the item you're interacting with as a variable at the top of your code so you can adjust it as a parameter in one place.

 

Finally, i'd recommend instead of using static sleep durations such as sleep(random(x,y));, you use conditional sleeps which wait until the magic tab /inventory / spell selected or whatever to determine what stage of the alch you are in. If it makes you feel more comfortable, you can add very small delays in-between, but I think the tick rate and network speed will account for atleast some randomness anyway.

 

Other than that, looks like it gets the job done, and congrats on writing your first script! Pretty good!

 

the next step is maybe a gui and/or paint! smile.png

 

~apa

PS i'm a pretty tired out so sorry if something I said didn't make sense, too tired to proof read

 

 

I will experiment with implementing conditional sleeps into the script and paint then and im using states since i plan on adding different types of antiban later on since when i decompiled some local scripts i found they all used switch so i guess it's more efficient? walking  Anyways thanks alot for the feedback :)

 

-erki

Switch cases are more organized, so I prefer them.

 

One suggestion I have is to use dynamic state detection to make your script more robust. Right now, you cycle from ALCH 1 to ALCH 3 and back. Imagine what might happen if the game lags after ALCH2, causing the spell to get deselected, however. Your script expects to be in ALCH3, but the spell will never get selected, causing your script to get stuck.

 

What I mean is:

 

onLoop() {

 

state = // code to figure out what state you should be in

switch (state) {

    // blah blah

}

 

}

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.