Jump to content

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


Recommended Posts

Posted

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)

Posted (edited)
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
Posted (edited)
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
Posted

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.

Posted (edited)
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
Posted (edited)

 

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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