Jump to content

How do I teleport with ring of wealth if certain conditions are met


theinadequacy

Recommended Posts

I'm trying to make it so that my character teleports to grand exchange if there is a specific NPC or an entity in the area. 

I'm using this code:

            NPC variableName = getNpcs().closest("npcName");
            Position current = myPlayer().getPosition();

   
            if (variableName != null);{
                getEquipment().interact(EquipmentSlot.RING, "Grand exchange");
                log("teleporting");
                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() {
                        return !myPlayer().getPosition().equals(current);
                    }
                }.sleep();
            }

After it teleports to GE it keeps on teleporting until it runs out of charges as if it doesn't recognize the if statement. Also logger throws this error:

[ERROR][Bot #1][10/26 05:33:05 PM]: Error executing event : org.osbot.rs07.event.InteractionEvent@36671a47
java.lang.NullPointerException
    at org.osbot.rs07.input.mouse.EquipmentSlotDestination.isVisible(sg:25)
    at org.osbot.rs07.event.InteractionEvent.execute(sl:729)
    at org.osbot.rs07.event.EventExecutor$2.run(ij:60)
    at org.osbot.rs07.event.EventExecutor.execute(ij:176)
    at org.osbot.rs07.script.MethodProvider.execute(bn:715)
    at org.osbot.rs07.api.Equipment.interact(wi:809)
    at Main.onLoop(Main.java:169)
    at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ro:134)
    at java.lang.Thread.run(Unknown Source)

Link to comment
Share on other sites

Just now, theinadequacy said:

I'm trying to make it so that my character teleports to grand exchange if there is a specific NPC or an entity in the area. 

I'm using this code:

            NPC variableName = getNpcs().closest("npcName");
            Position current = myPlayer().getPosition();

   
            if (variableName != null);{
                getEquipment().interact(EquipmentSlot.RING, "Grand exchange");
                log("teleporting");
                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() {
                        return !myPlayer().getPosition().equals(current);
                    }
                }.sleep();
            }

After it teleports to GE it keeps on teleporting until it runs out of charges as if it doesn't recognize the if statement. Also logger throws this error:

[ERROR][Bot #1][10/26 05:33:05 PM]: Error executing event : org.osbot.rs07.event.InteractionEvent@36671a47
java.lang.NullPointerException
    at org.osbot.rs07.input.mouse.EquipmentSlotDestination.isVisible(sg:25)
    at org.osbot.rs07.event.InteractionEvent.execute(sl:729)
    at org.osbot.rs07.event.EventExecutor$2.run(ij:60)
    at org.osbot.rs07.event.EventExecutor.execute(ij:176)
    at org.osbot.rs07.script.MethodProvider.execute(bn:715)
    at org.osbot.rs07.api.Equipment.interact(wi:809)
    at Main.onLoop(Main.java:169)
    at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ro:134)
    at java.lang.Thread.run(Unknown Source)

You need to check 3 things before you interact:
1. That you are actually wearing the ring.

2. that the equipment tab is open.

3. ring has charges.

Edited by HunterRS
Link to comment
Share on other sites

if api.getEquipment().isWearingItem(EquipmentSlot.RING, i -> i != null && i.getName().contains("Ring of wealth")) && !api.getEquipment().isWearingItem(EquipmentSlot.RING, "Ring of wealth");

that will check if your wearing a ring of wealth which has any charges but not wearing one with no charges

Edited by The Legman
  • Like 1
Link to comment
Share on other sites

I don't think the code itself is wrong, because it does open the inventory and teleports to GE and also getEquipment().interact(EquipmentSlot.RING, "Grand exchange"); statement should check if the ring has charges because a ring without charges doesn't have the "Grand exchange" option. 

Also if I put "if (variableName == null);" and the NPC/entity is close, it teleports anyway. So its really wierd.

Link to comment
Share on other sites

5 minutes ago, theinadequacy said:

I don't think the code itself is wrong, because it does open the inventory and teleports to GE and also getEquipment().interact(EquipmentSlot.RING, "Grand exchange"); statement should check if the ring has charges because a ring without charges doesn't have the "Grand exchange" option. 

Also if I put "if (variableName == null);" and the NPC/entity is close, it teleports anyway. So its really wierd.

Because you are doing == null

Also, post more of your code. Specifically line 169 in your Main class.

Edited by Viston
Link to comment
Share on other sites

 

30 minutes ago, Viston said:

Because you are doing == null

Also, post more of your code. Specifically line 169 in your Main class.

this is the whole thing. After it teleports to ge it keeps teleporting until it runs out of charges.

Also its not throwing the error atm but when it does it points to this line: getEquipment().interact(EquipmentSlot.RING, "Grand exchange");

case TELEPORT: 
            NPC emblemTrader = getNpcs().closest("Emblem Trader");
            Position current = myPlayer().getPosition();

            log("STARTINGGGGGGGGGGGG");  
            
            if (emblemTrader != null);{
                getEquipment().interact(EquipmentSlot.RING, "Grand exchange");
                log("teleporting");
                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() {
                        return !myPlayer().getPosition().equals(current);
                    }
                }.sleep();        
            }
            sleep(random(500, 600));
                        
            break;            

Edited by theinadequacy
Link to comment
Share on other sites

Its weird because anywhere in runescape it will teleport. What I want is that if there isn't a specific NPC in the area (when I arrive at the GE) it wont teleport again .

Edit: I think I'm using the IF statement wrong or there's something in the Eclipse

Edited by theinadequacy
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...