Skip 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.

Grab equipment on start

Featured Replies

I want to get worn equipment onStart and save the items to a string so i can re gear later on. Is this possible?

Something like :

String wornItems = getEquipment().getItems();

then later on i can do, if not wearing wornItems then bank, withdraw and equip wornItems.

Is it possible to use strings in this way, thanks in advance any help is appreciated

7 minutes ago, shaba123 said:

I want to get worn equipment onStart and save the items to a string so i can re gear later on. Is this possible?

Something like :

String wornItems = getEquipment().getItems();

then later on i can do, if not wearing wornItems then bank, withdraw and equip wornItems.

Is it possible to use strings in this way, thanks in advance any help is appreciated

Something like this may help you out :)

 

if (getEquipment().getItemInSlot(0) != null) {
                       String helmet = getEquipment().getItemInSlot(0).getName();

                    } 

private ArrayList<String> wornItems = new ArrayList<>();
  
private void grabEquipment() {
  
  Item[] items = getEquipment().getItems(); // Grabs our equipment
  
  for (Item i : items) { // for each item in the items array, loop
  	wornItems.add(i.getName()); // add the item to the array
  	log("Equipment Item Added: " + i.getName());
  }
  
 }

It's been a while since I've used the OSBot API, but this should do. Just put the grabEquipment() method in your onStart and store your wornItems as a variable somewhere.

Edited by HeyImJamie

  • Author
57 minutes ago, HeyImJamie said:

private ArrayList<String> wornItems = new ArrayList<>();
  
private void grabEquipment() {
  
  Item[] items = getEquipment().getItems(); // Grabs our equipment
  
  for (Item i : items) { // for each item in the items array, loop
  	wornItems.add(i.getName()); // add the item to the array
  	log("Equipment Item Added: " + i.getName());
  }
  
 }

It's been a while since I've used the OSBot API, but this should do. Just put the grabEquipment() method in your onStart and store your wornItems as a variable somewhere.

Hey that example worked but threw up some errors. Do you know why?

[INFO][Bot #1][05/24 03:09:45 PM]: Equipment Item Added: Blue wizard hat
[INFO][Bot #1][05/24 03:09:45 PM]: Equipment Item Added: Fire cape
[INFO][Bot #1][05/24 03:09:45 PM]: Equipment Item Added: Amulet of strength
[INFO][Bot #1][05/24 03:09:45 PM]: Equipment Item Added: Granite maul
[INFO][Bot #1][05/24 03:09:45 PM]: Equipment Item Added: Monk's robe top
[ERROR][Bot #1][05/24 03:09:45 PM]: Error in script onStart(): newScript
java.lang.NullPointerException
	at core.Main.grabEquipment(Main.java:113)
	at core.Main.onStart(Main.java:103)
	at org.osbot.rs07.event.ScriptExecutor.iiIiiiiiIiiI(kl:120)
	at org.osbot.rs07.event.ScriptExecutor.start(kl:129)
	at org.osbot.UB.run(dw:194)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

 

24 minutes ago, shaba123 said:

Hey that example worked but threw up some errors. Do you know why?


[INFO][Bot #1][05/24 03:09:45 PM]: Equipment Item Added: Blue wizard hat
[INFO][Bot #1][05/24 03:09:45 PM]: Equipment Item Added: Fire cape
[INFO][Bot #1][05/24 03:09:45 PM]: Equipment Item Added: Amulet of strength
[INFO][Bot #1][05/24 03:09:45 PM]: Equipment Item Added: Granite maul
[INFO][Bot #1][05/24 03:09:45 PM]: Equipment Item Added: Monk's robe top
[ERROR][Bot #1][05/24 03:09:45 PM]: Error in script onStart(): newScript
java.lang.NullPointerException
	at core.Main.grabEquipment(Main.java:113)
	at core.Main.onStart(Main.java:103)
	at org.osbot.rs07.event.ScriptExecutor.iiIiiiiiIiiI(kl:120)
	at org.osbot.rs07.event.ScriptExecutor.start(kl:129)
	at org.osbot.UB.run(dw:194)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

  

Probably need to null check getName(), show me what line 113 is and I'll tell you

  • Author

Line 113 is as so :

 

wornItems.add(i.getName());

42 minutes ago, HeyImJamie said:

Probably need to null check getName(), show me what line 113 is and I'll tell you

You were correct, works fine now with null check. Thank u sir

Edited by shaba123

21 minutes ago, shaba123 said:

Line 113 is as so :

 

wornItems.add(i.getName());

 

String itemName = i.getName();

if (itemName != null){

wornItems.add(itemName);

}

If you can't figure out how to implement a null check though having an equipment handler seems a little out of your depth for now.

  • Author
1 hour ago, HeyImJamie said:

String itemName = i.getName();

if (itemName != null){

wornItems.add(itemName);

}

If you can't figure out how to implement a null check though having an equipment handler seems a little out of your depth for now.

I said i added the null check, thanks 

6 hours ago, shaba123 said:

I said i added the null check, thanks 

My bad, I didn't see the edit. Happy scripting! :) 

  • Author
9 hours ago, HeyImJamie said:

My bad, I didn't see the edit. Happy scripting! :) 

Thank you sir :)

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.