Everything posted by Vilius
-
How to check if bot is cooking
Timer class: public class Timer { private long period; private long start; public Timer(long period) { this.period = period; this.start = System.currentTimeMillis(); } public long getElapsed() { return System.currentTimeMillis() - this.start; } public long getRemaining() { return this.period - this.getElapsed(); } public boolean isRunning() { return this.getElapsed() <= this.period; } public void setPeriod(long period) { this.period = period; } public void reset() { this.start = System.currentTimeMillis(); } public static String format(long milliSeconds) { long secs = milliSeconds / 1000L; return String.format("%02d:%02d:%02d", new Object[] { Long.valueOf(secs / 3600L), Long.valueOf(secs % 3600L / 60L), Long.valueOf(secs % 60L) }); } }Then simply implement it like this: Timer timer = new Timer(4000); if(myPlayer().isAnimating()){ timer.reset(); } if(timer.getElapsed() > 4000){ //do stuff } That should work, just change the 4000 into the time it takes to cook the whole inventory in milisecondsActually change the time it takes to cook one and the delay in between, 4000ms should work.
-
Trying to Understand Show/Hide Paint
Our mouse class public class Mouse implements MouseListener { //create a boolean public boolean hidePaint; @Override public void mouseClicked(MouseEvent e) { //create our point variable Point p = e.getPoint(); //create our rectangle Rectangle rec = new Rectangle(x,y,width,height); //check if the rectangle contains point and change booleans state if(rec.contains(p)) hidePaint = !hidePaint; } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } } Main class public class Main extends Script{ //pas our mouse object Mouse mouse = new Mouse(); public void onStart(){ //add our mouse object as a mouse listener getBot().addMouseListener(mouse); } public void onPaint(Graphics2D g){ //check if our boolean is false if(!mouse.hidePaint){ //draw our stuff } } public int onLoop(){ return 0; } } Hope this helps
-
[Help Request] Get dynamic Area + Hover next Object?
Find yourself a static object that doesnt change its position in any instance created and map out the areas from its position. For getting all objects you could use RS2Object[] objc = getObjects().getAll().stream().filter(o -> o != null && o.getId() == id && areaVar.contains(o));
-
Osbot dialogue changed, wont install webwalking.
The LAF might have changed, but it shouldnt affect any buttons with actions
-
Need some help with 'webwalking'
getWalking().webWalk(new Position(x,y,z)); The webWalk method needs a Position object to be passed into its parameters. Someone didn't want to overload the method much more
-
Anybody good in Physics?
http://hyperphysics.phy-astr.gsu.edu/hbase/cf.html http://www.s-cool.co.uk/a-level/physics/circular-motion/revise-it/angles-in-radians-and-angular-speed-versus-linear-speed goodluck
-
How to use inventory item on fire?
//interact with inventory getInventory().interact("Use", "item"); //check is item selected if(getInventory().isItemSelected()){ //get the fire object RS2Object fire = getObjects().closest("Fire"); //interact with fire fire.interact("Use"); } I'm guessing that is what you want to do.
-
Yet another IPTorrent invite giveaway!
ty for giveaway
-
Fishing script help
Oh, and you should always look at the logger and see what line the error occurs one ;)
-
Fishing spot
Just do this //position object Position pos = new Position(x,y,z); //Will check if name is right and will check if the position isnt the ignored one NPC fish = getNpcs().closest(o -> o.getName().equals("Fishing spot") && !o.getPosition().equals(pos)); //Interact with fish fish.interact("action");
-
Fishing spot
NPC spot = getNpcs().closest("Fishing spot"); Position pos = new Position(x,y,z); if(!spot.getPosition().equals(pos)){ //do stuff }
-
Re-sizing osbot client
Mmmm.... Seems like Ace has never heard of layout managers But to fix that try changing your screens resolution if you are using like a 4k monitor, that usually fixes it.
-
Help with my first script
Paste with comments to explain things. //we check if our inventory is full and we are in bank area. if (getInventory().isFull() && Banks.VARROCK_WEST.contains(myPlayer())) { //We are in the bank are, doing banking. //check if bank is open if(getBank().isOpen()){ //Bank open, we are depositing it getBank().depositAll(); }else{ //if bank is closed, open it. getBank().open(); } }else{ //We are walking to the bank area, because we are not in it. getWalking().webWalk(Banks.VARROCK_WEST); } Raw paste: Good luck
-
Ordered my Raspberry Pi 3!
What are your plans for it? :p
-
A Beginners Guide to Writing OSBot Scripts (where to get started!) by Apaec
This will withdraw a specific numbergetBank().withdraw("item", 5); This will withdraw all getBank().withdrawAll("item");
-
Question [Noob Scripter Starting Out]
Check your errors, if you have an x on your project or anywhere else in the code for that matter, look into it.
-
Can't set my profile pic?
Max 180x180px, an upload via url with a direct link.
- Hey I am back
-
[Guide]Types of Entities and how to use them correctly
Fixed
-
[Guide]Types of Entities and how to use them correctly
RuneScape has multiple entity types NPC's Objects GroundItems Determining which one to use is way simpler than people think. NPC's will have yellow name tags in game Objects will have blue name tags in game GroundItems will have orange name tags in game Now when it comes to declaring variables what should we use? For NPC's we would use the NPC class. Our code should look like this NPC npc = ... For Objects we would use the RS2Object class. Our Code should look like this RS2Object object = ... For GroundItems we would use the GroundItem class. Our code should look like this GroundItem item = ... Why would we shy away from using Entity class to define any entity from the game? Well simply put Entity is just an interface and it might not contain things needed to any specific Entity implementing classes. Like RS2Object will have getType() method but Entity will not. The main place to use Entity class is when we are passing it to a parameter of a method and making your own lets say interacting methods. We would use Entity in our parameter to make it accept any Entity type. public void interactCustom(Entity entity, String action){ if(entity.isVisible()) entity.interact(action); else getCamera().toEntity(entity); } Of course again there will come limitations, which are when you are making a method for getting the type of an Object and logging it. Having our code look like this will not work and give us an error. public void getTypeAndLog(Entity entity){ log("[Debug] objects type: " + entity.getType(); } So passing Entity to our parameter wouldn't give us the method getType() which RS2Object has, so we would need to have RS2Object in our parameter So we would need to have RS2Object in our parameter. And our code will work if he have it look like this public void getTypeAndLog(RS2Object object){ log("[Debug] objects type: " + object.getType(); } I hope this guide helped you understand the types of Entities and how to use them correctly
- New to OSBot Community
-
Multiple classes :doge:
And you said oop is useless ;)
-
Asking for template...
he said he wants to edit it, read the post pls
-
OSBot Meet up
You know that is harassment, do you?
-
Asking for template...
Look at local script section