Jump to content

Popymon24

Members
  • Posts

    18
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Popymon24

  1. I'm writing a woodchopping script that banks, and I need to get my character from the woodchopping area (position 1) to the bank (position 2). How would I go about having my character walk between the two points; what command would let me input an end position and have my character walk there?

  2. I'm working on a fishing and cooking script, and I want the bot to sleep until all of the raw trout in my inventory is cooked. The code that i have for my conditional sleep is: 

    1.  if (cookMenu != null && cookMenu.isVisible()) {
    2.                     cookMenu.interact("Cook All");
    3.                     new ConditionalSleep(600000) {
    4.                         @Override
    5.                         public boolean condition() throws InterruptedException {
    6.                             return inventory.onlyContains(314309331343333) || !myPlayer().isAnimating() ||getDialogues().inDialogue();
    7.                         }
    8.                     }.sleep();

    The problem is that it doesn't sleep, and continually selects the trout, uses it on the fire, and clicks "Cook All".

     

    Any help is appreciated!

  3. 
    
    import org.osbot.rs07.api.model.NPC;
    import org.osbot.rs07.api.model.RS2Object;
    import org.osbot.rs07.api.ui.RS2Widget;
    import org.osbot.rs07.script.Script;
    import org.osbot.rs07.script.ScriptManifest;
    
    import java.awt.*;
     
    @ScriptManifest(author = "You", info = "My first script", name = "Tea thiever", version = 0, logo = "")
    public class main extends Script {
     
        @Override
        public void onStart() {
            log("Let's get started!");
        }
        
        private enum State {
            FISH, COOK, DROP
        }
        
        private State getState() {
            if(inventory.isEmptyExcept(310, 17794, 309, 17795, 123, 17796) && !myPlayer().isAnimating())
                return State.FISH;
            if(inventory.isFull())
                return State.COOK;
            return State.DROP;
        }
     
        @Override
        public int onLoop() throws InterruptedException {
            switch(getState()) {
                case FISH:
                    //Entity fishingSpot = objects.closest("Fishing Spot"); Wrong. Fishing spots are tied to NPCs
    
                    //You meant to do:
                    NPC fishingSpot = getNpcs().closest("Fishing Spot");
                    if (fishingSpot != null) { //ALWAYS NULL CHECK BEFORE INTERACTING..Keep this in mind.   logic: if it exists -> interact
                        fishingSpot.interact("Lure");
                        //sleep
                    }
                    break;
                case COOK:
                    //Entity fire = objects.closest("fire"); This is okay to do since Object,NPC,etc extend Entity
                    //but should do it like this.
                    RS2Object fire = getObjects().closest("Fire");
                    RS2Widget cookMenu = widgets.get(307, 4);
    
                    //I am going to throw some code in here for you. It will be your job to find it in the API docs and understand the methods I am implementing.
                    if (cookMenu != null && cookMenu.isVisible()) {
                        cookMenu.interact("Cook All");
                        //sleep
                    } else {
                        if (getInventory().isItemSelected()) {
                            if (fire != null) {
                                fire.interact("Use");
                                //sleep...look into ConditionalSleep
                            }
                        } else {
                            //item is not selected..select something
                            inventory.interact("Use", "Trout");
                            //sleep
                        }
                    }
                    break;
                case DROP:
                    inventory.dropAll(331, 332, 333, 334, 25976);
                    break;
            }
            return 600; //just return a server tick 600ms
        }
     
        @Override
        public void onExit() {
            log("Thanks for running my first script!");
        }
     
        @Override
        public void onPaint(Graphics2D g) {
     
        }
     
    }
    

    Try this

     

    Holy crap. Thank you so much. I kinda rushed into scripting, and this helps a lot. Thanks for all the comments you left in it, I'll have a much better grasp next time I decide to write- and some more Java under my belt.

     

    EDIT:

    I went through and checked the ID's, and they were incorrect, which was why the script wasn't working. I had the wrong ID for the fishing rod, so it wasn't starting the FISH state.

  4. add this import

    import org.osbot.rs07.api.ui.RS2Widget;

    I code on Mac so this is what I do

    Whenever something is red, see if you need to add the import. Click on the red line, hold Option(ALT on windows?) and press enter it will add the import.

    i already had it imported. This is my code for the COOK state:

    case COOK:
            Entity fire = objects.closest("fire");
                inventory.interact("Use", "Trout");
            fire.interact("Use");
            if (getWidget.isVisible(307,2)) {
            getWidgets().interact(307,2 "Cooked All");
            }
        break;
     
    getWidget, interact, and "Cooked all" both have red lines.
     
    It is supposed to recognize the fire, select the trout, right click and click use on the fire, see if the widget is available, then select cook all.

     

    i already had it imported. This is my code for the COOK state:

    case COOK:
            Entity fire = objects.closest("fire");
                inventory.interact("Use", "Trout");
            fire.interact("Use");
            if (getWidget.isVisible(307,2)) {
            getWidgets().interact(307,2 "Cooked All");
            }
        break;
     
    getWidget, interact, and "Cooked all" both have red lines.
     
    It is supposed to recognize the fire, select the trout, right click and click use on the fire, see if the widget is available, then select cook all.

     

    I fixed the code.

     

             RS2Widget cookMenu = widgets.get(307,4);
            if(cookMenu != null && cookMenu.isVisible())
             cookMenu.interact("Cook All");

    I compiled it, and it does nothing. Here's my code:

     

    import org.osbot.rs07.api.model.Entity;
    import org.osbot.rs07.api.ui.RS2Widget;
    import org.osbot.rs07.script.Script;
    import org.osbot.rs07.script.ScriptManifest;
     
     
     
    import java.awt.*;
     
    @ScriptManifest(author = "You", info = "My first script", name = "Tea thiever", version = 0, logo = "")
    public class main extends Script {
     
        @Override
        public void onStart() {
            log("Let's get started!");
        }
        
        private enum State {
        FISH, COOK, DROP
        };
        
        private State getState() {
        if(inventory.isEmptyExcept(310, 17794, 309, 17795, 123, 17796))
        return State.FISH;
        if(inventory.isFull())
        return State.COOK;
        return State.DROP;
        }
     
        @Override
        public int onLoop() throws InterruptedException {
        switch(getState()){
        case FISH:
            Entity fishingSpot = objects.closest("Fishing Spot");
            fishingSpot.interact("Lure");
        break;
        case COOK:
            Entity fire = objects.closest("fire");
                inventory.interact("Use", "Trout");
            fire.interact("Use");
            RS2Widget cookMenu = widgets.get(307,4);
            if(cookMenu != null && cookMenu.isVisible())
             cookMenu.interact("Cook All");
        break;
        case DROP:
        inventory.dropAll(331, 332, 333, 334, 25976);
        break;
        }
            return random(200, 300);
        }
     
        @Override
        public void onExit() {
            log("Thanks for running my first script!");
        }
     
        @Override
        public void onPaint(Graphics2D g) {
     
        }
     
    }
  5.  

    Settings<Options<Debug<Tick Widgets on

     

    Now when you hover over things, it will give you numbers from a box.

    Find the #s it gives you and use them in

    if (getWidget.isVisible(#,#)) {
    getWidgets().interact(#,# "Cooked All");
    }
    

    The getWidgets and getWidget both have red lined underneath. 

  6.  

    You want to sleep until inventory contains 27 cooked fish (fishing rod is 1 space) or until you are in dialogue from leveling up.

      new ConditionalSleep(60000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getInventory.getAmount("Name of fish")>=27 || getDialogue.inDialogue;
                }
            }.sleep();

    You can use a widget to cook

    if (getWidget.isVisible(#,#) {
    getWidgets().interact(#,# "Cooked All");
    }

    I have no idea how to use widgets. This is my first script, I've barely ever programmed before, and only in C#.

  7.  

    To select item, use: 

              inventory.interact("Use", "Name of Fish");
    

    Use on the fire. I think fire is an object? Not sure I have never cooked. 

     

    getObject.closest("Name of whatever fire is").interact("Use");
    

    And what do you mean until inventory is empty? Like when you drop after cooking?

     

    
    getInventory.dropAllExcept("Fishing rod Name");

    I meant until all the fish were cooked. Thank you so much!

  8. fishing spot is npc, change ur code to npc

     

    objects are blue text when right clicked

    npcs are yellow

    But to cook on the fire you need to select the item you want to cook then use it on the fire. Also, how would I do this until my inventory is empty? Can you provide some example code?

  9. I wanted to make a script for OSBot, and decided that I wanted to make a script that fished at barbarian village and also cook the fish before dropping them. When I got to making the cooking part, I got stuck because I couldn't use interact on the fire like I could the fishing spots. Any help or touchups of what I have done are gladly welcomed!

     

    import org.osbot.rs07.api.model.Entity;
    import org.osbot.rs07.script.Script;
    import org.osbot.rs07.script.ScriptManifest;
     
     
    import java.awt.*;
     
    @ScriptManifest(author = "You", info = "My first script", name = "Tea thiever", version = 0, logo = "")
    public class main extends Script {
     
        @Override
        public void onStart() {
            log("Let's get started!");
        }
        
        private enum State {
        FISH, COOK, DROP
        };
        
        private State getState() {
        Entity fishingSpot = objects.closest("Fishing Spot");
        if(inventory.isEmptyExcept(123))
        return State.FISH;
        Entity fire = objects.closest("fire");
        if(inventory.isFull())
        return State.COOK;
        return State.DROP;
        }
     
        @Override
        public int onLoop() throws InterruptedException {
        switch(getState()){
        case FISH:
            Entity fishingSpot = objects.closest("Fishing Spot");
            fishingSpot.interact("Lure");
        break;
        case COOK:
            Entity fire = objects.closest("fire");
            fire.interact("Cook")
        break;
        case DROP:
        inventory.dropAll(331, 332, 333, 334, 25976);
        break;
        }
            return random(200, 300);
        }
     
        @Override
        public void onExit() {
            log("Thanks for running my Tea Thiever!");
        }
     
        @Override
        public void onPaint(Graphics2D g) {
     
        }
     
    }
  10. Also: the bot gets stuck sometimes as it will try to click tiles that aren't loaded because of how the camera is positioned. I suggest having the bot click closer to the center of the screen, or on the map, as the map loads faster than tiles.

     

    Thank you, and have a nice day!

    • Like 1
  11. Did you remember to clear the ore hopper before starting the script? Usually after that's setup, it will never have issues with collecting ore

     

    As for upstairs south mode, I will post a quick fix right now, thanks for feedback biggrin.png

    Yes, I did. To fix it, I just need to pause the script and deposit the rest of the pay-dirt into the input hopper, then collect it, and start the script. It hasn't happened many times, and I don't know how it happens. I make sure the bag is empty when I start.

     

    Thank you for your time and effort!

    • Like 1
  12. Hey, Czar, I love your scripts, I've bought three of them and loved every single one of them, with few problems. 

    However, I have found two glitches so far. 

     

    1. Sometimes, the bot will collect from the bag while still having pay dirt in its inventory (four or five from my experience), causing it to go back and forth between the bank chest and the cleaning hopper.

     

    2. While mining upstairs, the bot gets stuck in the southern part. I'm assuming this is because of the rockfall disconnecting it from the section of the upstairs mine with the ladder, and the bot can't get the rockfall into its view.

     

    Thank you, and have a nice day!

    • Like 2
×
×
  • Create New...