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.

Widgets & Genie Lamp

Featured Replies

I have no way to test or find without waiting for a genie to spawn, so thought I'd ask here

Does anyone know the widget code or have any existing scripts for handling the genie lamp?

private void randomHandler() throws InterruptedException {
        randomGenie();
        // Additional randoms
    }
    private void randomGenie() throws InterruptedException {
        final NPC genie = getNpcs().closest(npc -> npc != null && npc.getName().equals("Genie") && npc.getPosition().distance(myPosition()) <= 1);
        if (genie == null || !genie.exists()) {
            return;
        }
        log("Genie found. Attempting to talk...");
        genie.interact("Talk-to");
        if(Sleep.sleep(this,3000,() -> getInventory().contains("Lamp"))){
            getInventory().getItem("Lamp").interact("Rub");
            // Widget code
        }
        return;
    }

Just decided to put this here for anyone else looking for the same - just call randomHandler() at the start of the onloop :)

Feels like the Genie is definitely one people would actually click on, couple of others potentially depending on if the script is banking etc

  • 1 month later...

Fun piece of code! You’re right; having the genie 🧞‍♂️, I would also click it, just like most real players would. I’m not sure if you already have all the necessary widgets, but if not, let me know, and I can post them here if you respond to this post.

However, the code doesn’t consider who the genie is targeting. You’ll end up in an endless loop, trying to interact with the genie until it dissolves into thin air when the timer runs out.

Add some code to check if the genie is interacting with the player. You could maybe check the text, extract the name from the genie’s message, and see if it matches the current player. I’ll take a look at my code to see how I handled it.

Great snippet, keep it up! 👍🏻
 

9 hours ago, Wacky Jacky said:

Fun piece of code! You’re right; having the genie 🧞‍♂️, I would also click it, just like most real players would. I’m not sure if you already have all the necessary widgets, but if not, let me know, and I can post them here if you respond to this post.

However, the code doesn’t consider who the genie is targeting. You’ll end up in an endless loop, trying to interact with the genie until it dissolves into thin air when the timer runs out.

Add some code to check if the genie is interacting with the player. You could maybe check the text, extract the name from the genie’s message, and see if it matches the current player. I’ll take a look at my code to see how I handled it.

Great snippet, keep it up! 👍🏻
 

Add some code to check if the genie is interacting with the player. 

I think this is the best way to do it. Character has IsInteracting
So you can use
```

genieInstance.IsInteracting(myPlayer())

```

https://osbot.org/api/org/osbot/rs07/api/model/Character.html#isInteracting-org.osbot.rs07.api.model.Character-

  • Author
On 7/7/2024 at 6:10 PM, Wacky Jacky said:

I’m not sure if you already have all the necessary widgets, but if not, let me know, and I can post them here if you respond to this post.

Thanks, that would be awesome!

 

On 7/8/2024 at 3:45 AM, yfoo said:

Add some code to check if the genie is interacting with the player. 

I didn't realise isInteracting() is so broad in scope! It is only following the player, but this is good to know, thanks!

I have updated my code:

public final class myScript extends Script {
    private String playerName;
...
@Override
    public final int onLoop() throws InterruptedException {
        if(playerName == null){
            if(getClient().isLoggedIn()) {
                playerName = myPlayer().getName();
            }
        }
        else{
            randomHandler();
        }
...
}

    private void randomHandler() throws InterruptedException {
        randomGenie();
        // Additional randoms later
    }
    private void randomGenie() throws InterruptedException {
        final NPC genie = getNpcs().closest(npc -> npc != null && npc.getName().equals("Genie") && npc.getPosition().distance(myPosition()) <= 1);
        if (genie == null || !genie.exists()) {
            return;
        }
        if (!genie.isInteracting(myPlayer()) || (genie.getHeadMessage() != null && !genie.getHeadMessage().contains(playerName))) {
            return;
        }
        log("Genie found. Attempting to talk...");
        genie.interact("Talk-to");
        if(Sleep.sleep(this,3000,() -> getInventory().contains("Lamp"))){
            getInventory().getItem("Lamp").interact("Rub");
            // Widget code
        }
        return;
    }

 

Edited by Fanny

3 hours ago, Fanny said:

Thanks, that would be awesome!

 

I didn't realise isInteracting() is so broad in scope! It is only following the player, but this is good to know, thanks!

I have updated my code:

public final class myScript extends Script {
    private String playerName;
...
@Override
    public final int onLoop() throws InterruptedException {
        if(playerName == null){
            if(getClient().isLoggedIn()) {
                playerName = myPlayer().getName();
            }
        }
        else{
            randomHandler();
        }
...
}

    private void randomHandler() throws InterruptedException {
        randomGenie();
        // Additional randoms later
    }
    private void randomGenie() throws InterruptedException {
        final NPC genie = getNpcs().closest(npc -> npc != null && npc.getName().equals("Genie") && npc.getPosition().distance(myPosition()) <= 1);
        if (genie == null || !genie.exists()) {
            return;
        }
        if (!genie.isInteracting(myPlayer()) || (genie.getHeadMessage() != null && !genie.getHeadMessage().contains(playerName))) {
            return;
        }
        log("Genie found. Attempting to talk...");
        genie.interact("Talk-to");
        if(Sleep.sleep(this,3000,() -> getInventory().contains("Lamp"))){
            getInventory().getItem("Lamp").interact("Rub");
            // Widget code
        }
        return;
    }

 

There you go:
https://pastebin.com/raw/GiQtZFJs

On 7/9/2024 at 10:48 AM, Fanny said:

Thanks, that would be awesome!

 

I didn't realise isInteracting() is so broad in scope! It is only following the player, but this is good to know, thanks!

I have updated my code:

public final class myScript extends Script {
    private String playerName;
...
@Override
    public final int onLoop() throws InterruptedException {
        if(playerName == null){
            if(getClient().isLoggedIn()) {
                playerName = myPlayer().getName();
            }
        }
        else{
            randomHandler();
        }
...
}

    private void randomHandler() throws InterruptedException {
        randomGenie();
        // Additional randoms later
    }
    private void randomGenie() throws InterruptedException {
        final NPC genie = getNpcs().closest(npc -> npc != null && npc.getName().equals("Genie") && npc.getPosition().distance(myPosition()) <= 1);
        if (genie == null || !genie.exists()) {
            return;
        }
        if (!genie.isInteracting(myPlayer()) || (genie.getHeadMessage() != null && !genie.getHeadMessage().contains(playerName))) {
            return;
        }
        log("Genie found. Attempting to talk...");
        genie.interact("Talk-to");
        if(Sleep.sleep(this,3000,() -> getInventory().contains("Lamp"))){
            getInventory().getItem("Lamp").interact("Rub");
            // Widget code
        }
        return;
    }

 

I just came to tell you, your code works :) nicely done fam.
I ran it over night, I added the code to my with my dive training script (store) for testing, I woke up to 6 lamps in my inventory.
I did however remove the part about the head message, and I made the range two, [npc.getPosition().distance(myPosition()) <= 2] because the diver runs a lot and the distance might become bigger than 1.

But the code as is, should also do just fine.

Edited by Wacky Jacky

  • Author
5 hours ago, Wacky Jacky said:

I just came to tell you, your code works :) nicely done fam.

Sweet, good to know it actually works! Not had chance to test it since writing

Thanks for the widget numbers!

I get the distance part, depends if you are doing static vs dynamic skills

Out of curiousity - why not head message?

Edited by Fanny

2 hours ago, Fanny said:

Sweet, good to know it actually works! Not had chance to test it since writing

Thanks for the widget numbers!

I get the distance part, depends if you are doing static vs dynamic skills

Out of curiousity - why not head message?

No real reason, I have had false positives in the past, but probably a skill issue on my side 😂

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.