Jump to content

Lexhanatin

Members
  • Posts

    16
  • Joined

  • Last visited

  • Feedback

    100%

Profile Information

  • Gender
    Male

Recent Profile Visitors

964 profile views

Lexhanatin's Achievements

Newbie

Newbie (1/10)

2

Reputation

  1. It's my main, no botting done. Thanks, thought I need to verify my account to show I can pay. It's not like I'm botting, and I'm trading gp for a bond. Is that bad?
  2. I forgot to sell items before membership ran out. I need someone trade me a bond. I'll sell loot tab immediately and reimburse you for the bonds market value and give 2 mill as payment. Current bond value is ~6.5m So I will give 8.5m after. Loot tab pic attached with my account name as verification. REMOVED ON REQUEST Respond to thread if interested. Completed by natever - Fast, reliable, and helpful for my first use of the market. Thanks again bro.
  3. I found the problem in @liverare solution. Simply the portals name isn't "Portal". Extra tags are added to the name preventing the below code from working. portalNpc = npcs.closest("Portal"); portalObj = objects.closest("Portal"); Instead partial matching should be used instead. portalNpc = getNpcs().closestThatContains("Portal"); portalObj = getObjects().closestThatContains("Portal"); This will always find a portal. The second problem in the solution was the implementation of distance. The current instance of portal would be of type NPC or Object, but when comparing distances, another instance was deemed closer. This would prevent interaction. A possible reason for this could be that the current portal instance was being compared to a previous instances distance. I'm not sure. I fixed this by taking out the distance comparison. Below is the find product. private void bank() throws InterruptedException { log("Bank method"); if (getObjects().closest("Rune Essence") != null) { log("Rune Essence Exists"); portalNpc = getNpcs().closestThatContains("Portal"); portalObj = getObjects().closestThatContains("Portal"); if (portalNpc != null || portalObj != null) { log("Entity not null"); if (portalNpc != null) { log("Portal is NPC"); portalEntity = portalNpc; } if (portalObj != null) { log("Portal is Object"); portalEntity = portalObj; } if (portalEntity != null) { log("Portal Interaction"); if (portalEntity.interact("Exit", "Use")) { new ConditionalSleep(8000) { @Override public boolean condition() throws InterruptedException { return !myPlayer().isMoving(); } }.sleep(); } } } else { log ("Entity null"); } } I would like to thank everyone for helping me solve this problem over the week. Hopefully this thread will help people with similar problems in the future.
  4. @liverare Not sure why nothing is being detected. Edit: It works sometimes, but when nothing is detected it just stalls.
  5. Are you trying to sleep after you attempt to attack the rat? How is he sleeping until the rat is dead? It's until the rat is under attack?
  6. Previous thread: So it seems as if the portal in the rune essence mine changes types from object to NPC to whatever. I'm having trouble implementing a solution for this. I've used some of the ideas explored in the previous thread, but my understanding is still weak. I originally wanted to filter through both objects and NPCs but Chris told me this wasn't possible. Instead he suggested for me to add both types to a list then filter through them. // Is this the correct way of creating and adding to a list? // Create List <Object> portals = new ArrayList<>(); //Add portals.add(getObjects().getAll().stream().filter(object -> object.getName().contains("Portal")).findAny()); //Add portals.add(getNpcs().getAll().stream().filter(object -> object.getName().contains("Portal")).findAny()); I'm not sure how to interact with the list of type Object. I was thinking of iterating through the list checking if the object was present, then interacting with it, but you can't interact unless the list is <Entity> not <Object>. If the list is <Entity> it's difficult to add to it... Basically... I have no idea what I'm doing, and I need some more assistance :). It should be common knowledge now, but in case it's forgotten, I take a while to learn, so pls be patient :). EDIT Read the 4th post for the solution.
  7. Basically when you do... api.getNpcs().closest("Dairy cow").interact(); There is the potential for the script to break because the cow may not exist for a given moment. Instead you need to implement what Slut has said, a null check... NPC closestCow = api.getNpcs().closest("Dairy cow"); if (closestCow != null) { closestCow.interact(); } What this will do is check if the cow exists first. If it does, then it will interact with it. Without this your script will be stuck with an NPE if it detects the cow not existing for just a moment. By only interacting with the cow if it exists, you prevent the NPE from occurring, because you're only interacting with the cow if the null check passes. Without the null check you can potentially interact with a null object. Just because you see the cow doesn't mean the program sees it. The program may be firing the interaction before the cow exists. Hope this helps.
  8. I'm not sure why it isn't walking back. Check osbot log to see if any useful errors pop up (Settings > Toggle logger). To debug we need to understand why the problem is occurring, rather than guessing. Try placing some log messages after each if and see what's printed in the logs during the bug. This will show where the script is stuck. if (condition 1) { log("1"); // Rest of block code } else if (condition 2) { log("2"); // Rest of block code } Let us know what you find out.
  9. So I've made my first few scripts, basically just simple tasks all inside a main class. How can I now call that main class inside another class? For example: main class - fills jugs, banks, repeat. new class - timer class If time < 1 hour main class else end program Code snippet if it helps. import org.osbot.rs07.api.model.Character; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import java.util.Arrays; import java.util.List; import java.awt.*; @ScriptManifest(author = "Lexhanatin", info = "My first script", name = "Jug Filler", version = 0, logo = "") public class main extends Script { private Position[] path = { new Position(3253, 3426, 0), // Outside bank. new Position(3246, 3429, 0), new Position(3239, 3433, 0) // Fountain }; private Position[] path2 = { new Position(3239, 3433, 0), // Fountain new Position(3246, 3429, 0), new Position(3253, 3426, 0) // Outside bank. }; List toFill = Arrays.asList(path); List toBank = Arrays.asList(path2); @Override public void onStart() { log("Welcome to Jug Filler by Lexhanatin."); log("If you experience any issues while running this script please report them to me on the forums."); log("Enjoy the script!"); } private enum State { FILL, BANK, WAIT }; private State getState() { Entity fountain = objects.closest("Fountain"); NPC banker = npcs.closest("Banker"); if (inventory.getAmount("Jug") == 28 && fountain != null) return State.FILL; if ((banker != null) && inventory.getAmount("Jug of water") == 28 || (banker != null) && inventory.isEmpty()) return State.BANK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case FILL: getWalking().walkPath(toFill); sleep(500); Entity fountain = objects.closest("Fountain"); if (inventory.getAmount("Jug") == 28 && fountain != null) { inventory.interact("Use", "Jug"); sleep(random(80, 100)); if (inventory.isItemSelected()) { fountain.interact("Use", "Jug -> Fountain"); sleep(random(80, 100)); Character me = myPlayer(); if(myPlayer().isAnimating()) { sleep(5000); } } } sleep(random(5000, 10000)); break; case BANK: if (!getBank().isOpen()){ getBank().open(); } if(inventory.isEmpty()){ getBank().withdraw("Jug", 28); sleep(random(500, 800)); getBank().close(); } else if (inventory.isFull()) { getBank().depositAll(); sleep(random(500, 800)); getBank().withdraw("Jug", 28); sleep(random(500, 800)); getBank().close(); } else { getBank().close(); } break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onExit() { log("Thanks for running my Jug Filler!"); } @Override public void onPaint(Graphics2D g) { } }
  10. I had that already, I just forgot to add it into the code example. Sorry.
  11. SOLVED THANKES TO Juggles__________________________________________________________________________________________________________ I'm making a script that involves checking the amount of coins a player has in their inventory. At the moment it doesn't do anything. It doesn't even open the bank. Here is my code case BANK: if (!getBank().isOpen()){ getBank().open(); } else if (inventory.getAmount("Coins") < 500) { getBank().withdrawAll("Coins"); } else { getBank().close(); } break; It's pretty similar to this, so I'm not sure what I'm doing wrong. http://osbot.org/forum/topic/68196-get-the-amount-of-items-in-inventory/ Thanks.
×
×
  • Create New...