Jump to content

Wine Maker - Feedback Welcome - Noobie!


dartz

Recommended Posts

Hello, I'm dartz and this is my first OsBot script.  I've written a tab making bot on another client and recently came to osBot to write bots, improve my java skill, and not have to pay $8 a month. I know python fairly well, but I'm a noob at java. 

The script is very simple, but gets the job done. 

Fixed:

When checking the bank for grapes/jugs of water, it will not detect the items if they are at the corner of the screen.

  • Pros
    • Works
    • Has a Paint
  • Cons
    • Few comments  
    • simple if statements, no functions 
    • only works at the G.E.
    • No GUI

 

package osBots;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.util.concurrent.TimeUnit;

import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(name = "CookMate", version = 1.0, info = "", author = "Dartz", logo = "")
public class CookMate extends Script{
	
	// reaction times changed prior to posting..
	public int min = 1000;
	public int low = 2000;
	public int med = 3000;
	public int high = 5000;
	// item ids
	public int grapes = 1987;
	public int water = 1937;
	// Paint //
	public int batches;
	public int estWine;
	public int fontSize;
	public long timeBegan;
	public long timeRan;
	
	// Crucial to paint time working //
	public void onStart() {
		timeBegan = System.currentTimeMillis();
	}
	
	@Override
	public int onLoop() throws InterruptedException {
		if (!myPlayer().isAnimating()) {
			log("Standing still");
			if (!inventory.contains(grapes) & !inventory.contains(water)) {
				log("Inventory lacking grapes");
				objects.closest("Grand Exchange booth").interact();
				log("Clicked bank");
				sleep(1000);
				// smart depositing + paint implementation
				if (!inventory.isEmpty()) {
					if (inventory.contains(1995) | inventory.contains(1993)) {
						batches = batches + 1;
						estWine = estWine + 14;
						log("batches: " + batches);
					}
					log("depositing all");
					bank.depositAll();
				}
				if (!bank.contains(grapes) | !bank.contains(water)) {
					stop();
				}
				sleep(random(min,low));
				bank.withdraw(grapes, 14);
				sleep(random(min,low));
				bank.withdraw(water, 14);
				sleep(random(min,low));
				bank.close();
				log("Bank Closed");
				sleep(1000);
			}
		
			if (inventory.contains(grapes) & inventory.contains(water)) {
				inventory.getItem("Grapes").interact("Use");
				sleep(1000);
				inventory.getItem("Jug of water").interact("Use");
				sleep(1000);
				RS2Widget makeInterface = getWidgets().get(270,14,38);
				if (makeInterface != null) {
					if (makeInterface.isVisible());
					log("Make interface is visible!");
					makeInterface.interact();
					/*
					 * Wine making = 2 ticks
					 * 14 Wines = 16.8 secs
					 */
					sleep(random(13000,18000));
				}
			}
		}

		
		log("Gone through onLoop()");
		sleep(1000);
		return 500;
	}
	
	// BELOW: ONLY EFFECTS PAINT //
	public void onPaint(Graphics2D g) {
		Graphics2D gr = g;
		timeRan = System.currentTimeMillis() - this.timeBegan;
		fontSize = 16;
		Font crossHair = new Font("SANS_SERIF", Font.BOLD, fontSize);
		g.setColor(Color.BLACK);
		g.setFont(crossHair);
		// 17 pixels in between each other
		g.drawString("Estimated xp: " + (estWine*200), 555, 424);
		g.drawString("Run time: " + ft(timeRan), 555, 441);
		g.drawString("Batches made: " + batches + " (wines: "+estWine+")", 555, 458);
		
		
	}
	
	private String ft(long duration) {
        String res = "";
        long days = TimeUnit.MILLISECONDS.toDays(duration);
        long hours = TimeUnit.MILLISECONDS.toHours(duration) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
        long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration));
        long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration));
        if (days == 0) {
            res = (hours + ":" + minutes + ":" + seconds);
        } else {
            res = (days + ":" + hours + ":" + minutes + ":" + seconds);
        }
        return res;
    }
}

 

I used several tutorials on here and greatly appreciate this community.  I want to become a better programmer and community member.  If you have any resources that proved helpful, I'd greatly appreciate those as well.  I also started working on a shrimp fisher to get familiar with walking to and from the bank.

Edited by dartz
Link to comment
Share on other sites

12 minutes ago, dreameo said:

RIP.

The example is wrong.

The "bitwise and" is not appropriate in the way that it's used but it still works here.

The examples not wrong. 

boolean expressions are expressed as 0s or 1s and in the example they had 
 

int x =55;
if (x<50 & x>0)

so it'd be if (0 & 1) which (0 & 1) evaluate to 0 which is false.

you're right about it not being appropriate though.

Link to comment
Share on other sites

2 minutes ago, IDontEB said:

The examples not wrong. 

boolean expressions are expressed as 0s or 1s and in the example they had 
 


int x =55;
if (x<50 & x>0)

so it'd be if (0 & 1) which (0 & 1) evaluate to 0 which is false.

you're right about it not being appropriate though.

zz read it as the author saying the first expression is false and second is true.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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