theinadequacy Posted October 26, 2017 Share Posted October 26, 2017 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) Quote Link to comment Share on other sites More sharing options...
HunterRS Posted October 26, 2017 Share Posted October 26, 2017 (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 October 26, 2017 by HunterRS Quote Link to comment Share on other sites More sharing options...
The Legman Posted October 26, 2017 Share Posted October 26, 2017 (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 October 26, 2017 by The Legman 1 Quote Link to comment Share on other sites More sharing options...
theinadequacy Posted October 26, 2017 Author Share Posted October 26, 2017 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. Quote Link to comment Share on other sites More sharing options...
Viston Posted October 26, 2017 Share Posted October 26, 2017 (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 October 26, 2017 by Viston Quote Link to comment Share on other sites More sharing options...
theinadequacy Posted October 26, 2017 Author Share Posted October 26, 2017 (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 October 26, 2017 by theinadequacy Quote Link to comment Share on other sites More sharing options...
theinadequacy Posted October 26, 2017 Author Share Posted October 26, 2017 (edited) 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 October 26, 2017 by theinadequacy Quote Link to comment Share on other sites More sharing options...
whipz Posted October 26, 2017 Share Posted October 26, 2017 use area's over npc's Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted October 26, 2017 Share Posted October 26, 2017 (edited) Could try checking if the Npc is visible / can reach / is on screen or w/e. Edited October 26, 2017 by HeyImJamie Quote Link to comment Share on other sites More sharing options...
Viston Posted October 26, 2017 Share Posted October 26, 2017 1 hour ago, whipz said: use area's over npc's This^ Just grab the area you land on when you teleport. Then use that to check if you have teleported successfully. E.g YOURAREA.contains(myPlayer()); Quote Link to comment Share on other sites More sharing options...