Jump to content

A Beginners Guide to Writing OSBot Scripts (where to get started!) by Apaec


Recommended Posts

  • 2 weeks later...
Posted (edited)

So, say i wanted to use an item with a fire, how would i do this? Like this?

if (getInventory().isFull()) 
        {
            getInventory().contains("Trout");
            {
                getInventory().use("Trout") RS2Object  Fire = getObjects().closest("Fire");; 
            }

I've been trying to find how to use fires to cook in the api, but can't find an object, or interactable for fire

Edited by mitsuki
Posted
11 hours ago, mitsuki said:

So, say i wanted to use an item with a fire, how would i do this? Like this?


if (getInventory().isFull()) 
        {
            getInventory().contains("Trout");
            {
                getInventory().use("Trout") RS2Object  Fire = getObjects().closest("Fire");; 
            }

I've been trying to find how to use fires to cook in the api, but can't find an object, or interactable for fire

Well, it looks like you've correctly defined the fire:

RS2Object fire = getObjects().closest("Fire");

Then all you have to do is select the item in your inventory:

getInventory().interact("Trout", "Use");

.. and once that is selected (you will have to add checks for this), you can interact with the fire:

fire.interact("Use");

-Apa

Posted
if (getInventory().isFull()) 
        {
            getInventory().contains("Trout");
            {
                RS2Object  Fire = getObjects().closest("Fire");
                {
                   getInventory().interact("Trout", "Use");
                   {
                       fire.interact("Use);
                   }
                }
            }

So it would be like that? I'm just confused because i didn't find anything about using a fire or anything in the api. Cheers for the help

Posted (edited)
1 hour ago, mitsuki said:

if (getInventory().isFull()) 
        {
            getInventory().contains("Trout");
            {
                RS2Object  Fire = getObjects().closest("Fire");
                {
                   getInventory().interact("Trout", "Use");
                   {
                       fire.interact("Use);
                   }
                }
            }

So it would be like that? I'm just confused because i didn't find anything about using a fire or anything in the api. Cheers for the help

 kinda inefficient-> its going to resupply with 27 or 26 raw trout.

try to use: for loops, or events :) 

Edited by extatus
  • Like 1
Posted
3 hours ago, mitsuki said:

if (getInventory().isFull()) 
        {
            getInventory().contains("Trout");
            {
                RS2Object  Fire = getObjects().closest("Fire");
                {
                   getInventory().interact("Trout", "Use");
                   {
                       fire.interact("Use);
                   }
                }
            }

So it would be like that? I'm just confused because i didn't find anything about using a fire or anything in the api. Cheers for the help

There's no specific reference to 'fire' in the API - we're working with Java objects here.

It seems you've got the brackets and semi colons a little confused as well, it might be worth looking up some basic java tutorials to get the basics down before trying to do this :)

Apa

  • Like 1
Posted
1 hour ago, extatus said:

 kinda inefficient-> its going to resupply with 27 or 26 raw trout.

try to use: for loops, or events :) 

Ohh, i thought that everything within the curly brackets would be handled first, so if you nest another line of code within another set of them, i thought that would happen first 

9 minutes ago, Apaec said:

There's no specific reference to 'fire' in the API - we're working with Java objects here.

It seems you've got the brackets and semi colons a little confused as well, it might be worth looking up some basic java tutorials to get the basics down before trying to do this :)

Apa

okay, thanks guys

  • 3 months later...
Posted

 

@Apaec - This is a fantastic guide. We all very much appreciate you taking the time to create this. Thanks :)

I'm familiar with basic Java programming concepts but don't know anything about the osbot API, so will have to get used to that and the nomenclature for finding objects around me once i start making scripts. I do have a particular question about the mouse movements, patterns, speeds, etc. How do we control this within our script? My initial thought is that when i pickup something, attack something, etc. using a bot then my mouse will fly across the screen with super precision or just appear elsewhere (as if using a touchpad?) and this would lead me to be banned immediately by the detection software. Does this happen? How do we control these mouse elements which would give away "bot-like behavior" ?  

And for this very simple tea thieving script that you've written via tutorial - is this actually functional? Or would the script click on the same identical spot of the tea stall and we'd be banned in 10 minutes? I'm trying to understand the level of randomization (mouse speed, pattern, delays, click positions) that is necessary in the scripts so we don't get banned in <10 minutes. (obviously at the beginning levels). Thoughts? 

And if this has already been discussed in another thread, please direct me to it! thanks! 

Posted
9 hours ago, laxdude815 said:

 

@Apaec - This is a fantastic guide. We all very much appreciate you taking the time to create this. Thanks :)

I'm familiar with basic Java programming concepts but don't know anything about the osbot API, so will have to get used to that and the nomenclature for finding objects around me once i start making scripts. I do have a particular question about the mouse movements, patterns, speeds, etc. How do we control this within our script? My initial thought is that when i pickup something, attack something, etc. using a bot then my mouse will fly across the screen with super precision or just appear elsewhere (as if using a touchpad?) and this would lead me to be banned immediately by the detection software. Does this happen? How do we control these mouse elements which would give away "bot-like behavior" ?  

 And for this very simple tea thieving script that you've written via tutorial - is this actually functional? Or would the script click on the same identical spot of the tea stall and we'd be banned in 10 minutes? I'm trying to understand the level of randomization (mouse speed, pattern, delays, click positions) that is necessary in the scripts so we don't get banned in <10 minutes. (obviously at the beginning levels). Thoughts? 

And if this has already been discussed in another thread, please direct me to it! thanks! 

Hey,

The API does take a bit of getting used to, but if you've used other APIs in the past, it shouldn't be too bad.

As for mouse movements, most of this is abstracted away. OSbot handles all of the low level mouse interactions, and exposes a high level API for you to work with. As a result, the mouse doesn't 'teleport' as you alluded to, rather the movement is smooth and nonlinear. You can visualise this by adding a pixel trail to the mouse pointer in the paint method (or there might be a debug option to enable moues trail? not sure).

The tea thieving script is functional, but very basic. For example, it will spam-click the stall when tea is available.

Rather than me writing a paragraph about bans, i'd suggest having a read of this: https://osbot.org/forum/topic/124429-preventing-rs-botting-bans-v3/

Best

Apa

  • 1 month later...
  • 1 month later...

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...