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.

Open source GlassBlower

Featured Replies

Hello everybody,

This is meant for learning purposed. Im not saying im the best, im sure i could learn more stuff. Im sure this could help others. Please note you have to have some knowledge of java because im not releasing everything. But some stuff, so there might be thing missing but if you know enough of java you could see it.

 

i released my inventory listener. LINK

 

Data class: Dont mind the static part, i have one whole class with separate static classes datas.

	public static class GlassBlower	{
		private static final int PARENT = 542;

		public enum Type	{
			BEER_GLASS(1, 18, 104),
			CANDLE_LANTERN(4, 20, 105),
			OIL_LAMP(12, 25, 106),
			VAIL(33, 35, 102),
			FISHBOWL(42, 43, 108),
			UNPOWERED_ORB(46, 53, 113),
			LANTERN_LENS(49, 55, 93),
			DORGESHUUN_LIGHT_ORB(87, 70, 140);

			private int level, exp, child;
			private String itemName;

			Type(int level, int exp, int child)	{
				this.level = level;
				this.exp = exp;
				this.child = child;
				this.itemName = super.name().replace("_", " ").toLowerCase();
			}

			public int level()	{
				return this.level;
			}

			public int exp()	{
				return this.exp;
			}

			@Override
			public String toString()	{
				return this.itemName;
			}

			public RS2InterfaceChild getInterface(Script s)	{
				return s.interfaces.getChild(PARENT, this.child);
			}
		}
	}

 

I have a Main class that handles everything


Variables:

	public static Timer keyboardTimer, waitTimer;	
	public static DsAPI dsAPI;	

condition sleep

	public ConditionalSleep conSleep(final boolean condition, int time)	{
		return new ConditionalSleep(time)	{
			@Override
			public boolean condition() throws InterruptedException {
				return condition;
			}
		};
	} 

 

The my sub class GlassBlower.

package scripts;

import java.awt.Graphics2D;
import org.osbot.rs07.api.Bank;
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.Script;

import core.AIOCrafter;
import core.Data;
import core.Data.DMode;
import core.Data.GlassBlower;
import dependencies.DsAPI;
import dependencies.settings.DsAbstractScript;
import dependencies.settings.DsNode;
import dependencies.web.WebBank;

public class DsGlassblower extends DsAbstractScript	{
	
	private DsNode[] nodeList = new DsNode[] {new DsBank(), new Glassblow()};
	private String status;
	private int total = 0, hoverAmount;
	private DsAPI dsAPI;
	private GlassBlower.Type type;
	private boolean enterAmount;
	
	private Bank bank;
	private Inventory inventory;
	//private Player myPlayer;
	
	public DsGlassblower(GlassBlower.Type type) {
		this.dsAPI = AIOCrafter.dsAPI;
		this.type = type;
		this.bank = sI().bank;
		this.inventory = sI().inventory;
		//this.myPlayer = sI().myPlayer();
	}	
	
	@Override
	public void handleAdded(Item item) {
		if (item != null){
			String name = item.getName();
			if (name.equalsIgnoreCase(type.toString()))	{
				AIOCrafter.waitTimer.reset();
				total++;
			}
		}
	}

	@Override
	public void handleRemoved(Item item) {}

	@Override
	public boolean oldScript() {
		return false;
	}

	@Override
	public void onPaint(Graphics2D g) {
		g.drawString("status: " +this.status, 560, 370);
		g.drawString("Total: " +this.total, 560, 390);
	}

	@Override
	public Script sI() {
		return AIOCrafter.script;
	}
	
	public void log(String name)	{
		sI().log(name);
	}
	
	@Override
	public String Manifest() {
		return DMode.GLASS_BLOWER.toString();
	}

	@Override
	public int onLoop() throws InterruptedException {
		for (DsNode DsNode: nodeList)	{
			if (DsNode.activate())	{
				this.status = DsNode.status();
				DsNode.run();
				break;
			}
		}
		return 700;
	}
	
	private class DsBank implements DsNode	{

		@Override
		public String status() {
			return "Banking: ";
		}

		@Override
		public boolean activate() throws InterruptedException {
			return !dsAPI.containsAll(true, Data.GLASSBLOWING_PIPE, Data.MOLTEN_GLASS);

		}

		@Override
		public void run() throws InterruptedException {
			if (!bank.isOpen()){
				openBank();
			}else{
				if (sI().bank.depositAllExcept(Data.GLASSBLOWING_PIPE, Data.MOLTEN_GLASS))	{
					withdrawSupplys();
				}
			}
		}
		
		private void openBank()	{
			Entity banker = dsAPI.getWebBank().getClosestBank();

			if (banker != null)	{ 
				if (!banker.isVisible())
					sI().camera.toEntity(banker, true);
				else{
					banker.interact(WebBank.bankActions);
					dsAPI.conSleep(bank.isOpen(), 5000).sleep();
				}
			}				
		}

		private void withdrawSupplys()	{
			if (!sI().inventory.contains(Data.GLASSBLOWING_PIPE)){
				if (sI().bank.contains(Data.GLASSBLOWING_PIPE))	{
					sI().bank.withdraw(Data.GLASSBLOWING_PIPE, 1);
					dsAPI.conSleep(inventory.contains(Data.GLASSBLOWING_PIPE), 7000).sleep();
				}else{
					sI().log("Bank doesnt contain glassblowing pipe");
					sI().stop(AIOCrafter.stop);
				}
			}
			else if (!sI().inventory.contains(Data.MOLTEN_GLASS))	{
				if (sI().bank.contains(Data.MOLTEN_GLASS))	{
					if (AIOCrafter.debug)	{	
						sI().bank.withdraw(Data.MOLTEN_GLASS, 10);	
					}else{
						sI().bank.withdrawAll(Data.MOLTEN_GLASS);	
					}
					dsAPI.conSleep(inventory.contains(Data.MOLTEN_GLASS), 7000).sleep();
				}else{
					sI().log("Bank doesnt contain molten glass");
					sI().stop(AIOCrafter.stop);
				}
			}
		}}
	
	private class Glassblow implements DsNode	{

		@Override
		public String status() {
			return "Blowing: " +type.toString();
		}


		@Override
		public boolean activate() throws InterruptedException {
			return true;
		}

		@Override
		public void run() throws InterruptedException {
			if (sI().bank.isOpen())	{
				sI().bank.close();
			}else{
				if (sI().tabs.open(Tab.INVENTORY))	{
					//add in moving item in inv
					if (AIOCrafter.waitTimer.getElapsed() > 3000)	{
						selectOption();						
					}
					if (AIOCrafter.waitTimer.getElapsed() <= 3000)	{
						mouseIsWaiting(hoverAmount, dsAPI.getWebBank().getClosestBank());
						inventory.deselectItem();
					}
				}
			}
		}
		
		private void mouseIsWaiting(int amount, Entity e)	{
			if (sI().inventory.getAmount(Data.MOLTEN_GLASS) > amount)	{
				if (sI().mouse.isWithinCanvas())
					sI().mouse.moveOutsideScreen();
			}else{
				if (e != null)	{
					if (!e.isVisible())
						sI().camera.toEntity(e);
					else
						e.hover();
				}
			}
		}
				
		public void selectOption() throws IllegalArgumentException, InterruptedException	{
			if (enterAmount)	{	enterAmount();	}
			else{
				if (type.getInterface(sI()) != null)	{
					if (type.getInterface(sI()).interact("make x"))	{
						AIOCrafter.keyboardTimer.reset();
						enterAmount = true;
						AIOCrafter.sleep(200, 100);			
					}
				}else{
					if (sI().inventory.getSelectedItemName() == null)	{
						sI().inventory.interact("use", Data.GLASSBLOWING_PIPE);
						dsAPI.conSleep(inventory.isItemSelected(), 7000);			
					}else{
						if (sI().inventory.getSelectedItemName().equalsIgnoreCase(Data.GLASSBLOWING_PIPE))	{
							sI().inventory.interact("use", Data.MOLTEN_GLASS);
							AIOCrafter.sleep(600, 100);			
						}else{
							sI().inventory.deselectItem();	
						}
					}
				}
			}
		}
		
		private int enterAmount() throws IllegalArgumentException, InterruptedException 	{
			hoverAmount = MethodProvider.random(2, 10);
			int number = MethodProvider.random(30, 50);

			if (dsAPI.isInterfaceOverChat())	{
				sI().keyboard.typeString(Integer.toString(number), true);
				enterAmount = false;
				AIOCrafter.sleep(1000, 100);			
			}else{
				while(AIOCrafter.keyboardTimer.getElapsed() > 3000)	{
					enterAmount = false;
					break;
				}
			}
			return 300;
		}
	}
}

Edited by josedpay

  • Author

Nice contribution, your code has definitely improved since the last time I saw you open source something smile.png

thank you :D

 

For everybody: In my main class i have static timers since most of the script require to enter how much items you want to make.. All use the same method with the same static variable. Its meant for less typing. 

Guest
This topic is now closed to further replies.

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.