Jump to content

Getting central point of an object


lovelypker

Recommended Posts

Hey guys I'm working on my first script and I'd like to use an inventory item on an RS object. I couldn't find anything in the API on how to do this so I figured all I needed to do was select the item in the inventory and then click on the RS object to use them together. In order to do this I am using mouse#move but can't figure out how to get the central point (or any point for that matter) of the entity.

 

I know this is a very basic question but it's my first go so any help would be appreciated!

Link to comment
Share on other sites

Hey guys I'm working on my first script and I'd like to use an inventory item on an RS object. I couldn't find anything in the API on how to do this so I figured all I needed to do was select the item in the inventory and then click on the RS object to use them together. In order to do this I am using mouse#move but can't figure out how to get the central point (or any point for that matter) of the entity.

 

I know this is a very basic question but it's my first go so any help would be appreciated!

It's not perfect, but you can get center x and y in the Rectangle class included in Java.

Link to comment
Share on other sites

Select inventory item

 

if inventory item selected interact use with rs2object

 

see leaked nudes of kate upton

 

acquire virus that downloads child porn from russia

 

get raided by fbi/nsa/cia/fyg

 

have hard life in prison

 

escape

 

#profit

I tried that but it wouldn't use the item with object.

After i had selected the item my code was

bankbox.interact("Use Bones ->");

but that did nothing

 

wut

 

(int) doubleVar

 

#casting

I tried casting but that's when I got the error that double cannot be dereferenced. Maybe I made a mistake.

Link to comment
Share on other sites

Well judging from the original question I'm just going to go ahead and answer this for you without reading the off-topic stuff, for your first script you should start with the basics and not worry about getting the central points: 

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

if(!inventory.isItemSelected){
   inventory.interact(COMMAND_HERE,ITEM_ID/NAME HERE);
}
sleep(gRandom(50,250));
fire.interact("Use");

That's the most simplest way to do it, yes yes not the best but for the purpose of the question it does the trick. All this would do is interact with the inventory item if none is selected and then interact withe RS2Object.

 

Hope you find that useful happy.png

Link to comment
Share on other sites

Well judging from the original question I'm just going to go ahead and answer this for you without reading the off-topic stuff, for your first script you should start with the basics and not worry about getting the central points: 

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

if(!inventory.isItemSelected){
   inventory.interact(COMMAND_HERE,ITEM_ID/NAME HERE);
}
sleep(gRandom(50,250));
fire.interact("Use");

That's the most simplest way to do it, yes yes not the best but for the purpose of the question it does the trick. All this would do is interact with the inventory item if none is selected and then interact withe RS2Object.

 

Hope you find that useful happy.png

You can get a MouseDestination for it. Create an EntityDestination (subclass of MouseDestination) like this:

EntityDestination dest = new EntityDestination(bot, object);

and then click the mouse at that destination

getMouse().click(dest);

 

I'd like to thank you both for your help!

 

Ended up figuring out what I was doing wrong with casting so I got it to find the central point but these are nice methods to know as well

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...