Jump to content

wallnuts5

Members
  • Posts

    5
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

Recent Profile Visitors

616 profile views

wallnuts5's Achievements

Newbie

Newbie (1/10)

2

Reputation

  1. Thanks for the help! Would you suggest I define my WebWalkEvents at the top of my script as public (where i have them in the above source) or should i define them right before I call them?
  2. I have actually run into the same error as OP (and I have a script manifest in mine). Sorry that my code is so cobbled together but the source is below. Also, if anyone has any tips they would be greatly appreciated. Thanks! EDIT: I found it was something to do with my WebWalkEvent "toCraftAltar". I removed it and simply placed a webWalk and it worked. import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.event.WebWalkEvent; import org.osbot.rs07.api.webwalk.INodeRouteFinder; import org.osbot.rs07.utility.*; import org.osbot.rs07.api.map.constants.*; import java.awt.Color; import java.awt.*; @ScriptManifest(name = "WaterCrafter", author = "WallNuts", version = 1.0, info = "", logo = "") public class Main extends Script { Area altararea = new Area(new Position(3181, 3168, 0), new Position(3183, 3163, 0)); Area bankarea = Banks.DRAYNOR; Area altar2area = null; long crafted = 0; int needThing, equip = 0; public WebWalkEvent toBank = new WebWalkEvent(INodeRouteFinder.createAdvanced(), new Position(3092, 3243,0)); public WebWalkEvent toAltar = new WebWalkEvent(INodeRouteFinder.createAdvanced(), new Position(3183,3165,0)); public WebWalkEvent toCraftAltar = new WebWalkEvent(INodeRouteFinder.createAdvanced(), altar2area.getRandomPosition()); @Override public void onStart() { log("Script begins"); //Code here will execute before the loop is started } private enum State { CRAFT, DROPOFF, WAIT, } private State getState() { if (inventory.contains("Rune Essence")) return State.CRAFT; if (inventory.contains("Water Rune") || !inventory.contains("Rune Essence")) return State.DROPOFF; return State.WAIT; } @Override public void onExit() { log("Script ends"); //Code here will execute after the script ends } @Override public int onLoop() throws InterruptedException { switch (getState()) { case CRAFT: if(equip == 1){ while(!getEquipment().contains("Water Tiara")) { bank.close(); getInventory().interact("Wear", "Water Tiara"); sleep(random(500, 1000)); } equip = 0; } toAltar.setBreakCondition(new Condition() { //if true, break the walker. @Override public boolean evaluate() { return altararea.contains(myPosition()); //area.contains(myPos) || pos.distance() <= threshold } }); execute(toAltar); log("to the altar"); Entity altar1 = objects.closest("Mysterious Ruins"); if (altar1 != null) { sleep(random(200, 600)); altar1.interact("Enter"); log("teleported"); sleep(random(2000, 3000)); } Entity altar2 = objects.closest("Altar"); while (!inventory.contains("Water rune")) { if (altar2 != null) { log("Found altar"); if(!altar2.isVisible()){ altar2area = altar2.getArea(2); toCraftAltar.setBreakCondition(new Condition() { //walking to crafting altar b/c always finds it but has problems interacting @Override public boolean evaluate() { return !altar2.isVisible(); } }); execute(toCraftAltar); sleep(1000); if(!altar2.isVisible()){// if the conditional walking over didn't work webwalk on over walking.webWalk(altar2area); } log("couldn't click"); } if(altar2.interact("Craft-rune")){ sleep(random(1000, 2500)); break; } sleep(random(1000, 2500)); } sleep(random(500, 750)); } if(inventory.contains("Water Rune")){ crafted = crafted + inventory.getAmount("Water rune"); } sleep(300); break; case DROPOFF: Entity portal = objects.closest("portal"); if(portal != null){ sleep(random(200, 600)); if(portal.interact("Use")){ while(myPlayer().isMoving()){ sleep(random(2000, 3500)); } } } skills.hoverSkill(Skill.RUNECRAFTING);//in case watching bot get a check on lvl sleep(random(800, 1500)); toBank.setBreakCondition(new Condition() { @Override public boolean evaluate() { return bankarea.contains(myPosition()); } }); execute(toBank); log("To the bank."); if(getEquipment().contains("Water Tiara") || getInventory().contains("Water Talisman")){//if need to take out water talisman or tiara needThing = 0; } else{ needThing = 1; } if(bankarea.contains(myPosition())) { if(random(10)>2){//80% of time use bank booth log("Bank booth"); RS2Object bank = getObjects().closest("Bank booth"); if (bank != null) { if (bank.interact("Bank")) { while(inventory.contains("Water rune")){ getBank().depositAll("Water rune"); sleep(random(500, 2000)); } sleep(random(1000, 2000)); if(needThing ==1 && getBank().contains("Water Tiara") || getBank().contains("Water talisman")){//if need to get talisman or tiara withdraw it if(getBank().contains("Water Tiara")){ getBank().withdraw("Water Tiara", 1); equip = 1; //make note to equip later } else{ getBank().withdraw("Water Talisman", 1); } } if(getBank().contains("Rune essence")){ while(!inventory.contains("Rune essence")){ getBank().withdrawAll("Rune essence"); sleep(random(500, 1500)); }} else{ log("no rune ess"); sleep(1000); if(!getBank().contains("Rune essence")){ stop(); //no rune ess logout } } } } } else{ log("Banker"); NPC banker = npcs.closest("Banker"); if (banker != null) { if (banker.interact("Bank")) { while(inventory.contains("Water rune")){ getBank().depositAll("Water rune"); sleep(random(500, 2000)); } sleep(random(1000, 2000)); if(needThing ==1 && getBank().contains("Water Tiara") || getBank().contains("Water talisman")){ if(getBank().contains("Water Tiara")){ getBank().withdraw("Water Tiara", 1); equip = 1; } else{ getBank().withdraw("Water Talisman", 1); } } if(getBank().contains("Rune essence")){ while(!inventory.contains("Rune essence")){ getBank().withdrawAll("Rune essence"); sleep(random(500, 1500)); }} else{ log("no rune ess"); sleep(1000); if(!getBank().contains("Rune essence")){ stop(); } } } } } } else{ toBank.setBreakCondition(new Condition() { //if true, break the walker. @Override public boolean evaluate() { return bankarea.contains(myPosition()); //area.contains(myPos) || pos.distance() <= threshold } }); execute(toBank); sleep(400); } break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) g.setColor(Color.yellow); g.drawString("Water runes crafted: " + String.valueOf(crafted), 10, 20); Point mP = getMouse().getPosition(); g.drawLine(mP.x - 5, mP.y + 5, mP.x + 5, mP.y - 5); g.drawLine(mP.x + 5, mP.y + 5, mP.x - 5, mP.y - 5); } }
  3. Please excuse my ignorance (only written 2 scripts ever) but to run this I understand I need to call WebBank.getNearest(x); but what do I put in for x? Do I put in (Script name_of_my_script)? Thanks in advance!
×
×
  • Create New...