minedas Posted January 17, 2015 Share Posted January 17, 2015 So i used other user source and edited to work as clay softner but it isnt working correctly,it just goes to well and stands there and i dont know is it softs the clay since it doesnt fill buckets.Heres edited script import java.awt.Color; import java.awt.Graphics2D; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.input.mouse.MiniMapTileDestination; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.Area; import org.osbot.rs07.api.model.Entity; @ScriptManifest(author = "", info = "", name ="", version = 0.0, logo = "") public class Cooker extends Script { private long startTime; private String status = "Initializing"; private Color bg; String state; @SuppressWarnings("unused") private Color box; public int statsX; public int statsY; public void onStart() { startTime = System.currentTimeMillis(); bg = new Color(69, 53, 15, 125); box = new Color(0, 0, 0); statsX = 313; statsY = 344; } public void onPaint(Graphics2D g1) { long millis = System.currentTimeMillis() - startTime; Graphics2D g = g1; g.setColor(bg); g.fillRect(statsX, statsY, 184, 115); g.setColor(Color.green); g.drawRect(statsX, statsY, 184, 115); g.setColor(Color.white); g.drawString((new StringBuilder("")).append("0.1 | Author : IkNight").toString(), statsX + 5, statsY + 15); g.drawString((new StringBuilder("State: ")).append(status).toString(), statsX + 5, statsY + 30); g.drawString((new StringBuilder("Time ran: ")).append(timeToString((int)millis)).toString(), statsX + 5, statsY + 45); g.drawString((new StringBuilder("Softened/Hour: ")).append(perHour((int)(statsX), System.currentTimeMillis() - millis)).toString(), statsX + 5, statsY + 75); } public void walkPath(Position[] path) throws InterruptedException { for (Position p : path) { if (myPosition().distance(p) > 16 || myPosition().distance(p) < 3) continue; boolean success; do { success = walkTile(p); } while (!success); } } public boolean walkTile(Position p) throws InterruptedException { if (myPosition().distance(p) > 13) { Position pos = new Position(((p.getX() + myPosition().getX()) / 2) + random(-3, 3), ((p.getY() + myPosition().getY()) / 2) + random(-3, 3), myPosition().getZ()); walkTile(pos); } mouse.click(new MiniMapTileDestination(bot, p), false); int fail = 0; while (myPosition().distance(p) > 2 && fail < 10) { sleep(500); if (!myPlayer().isMoving()) fail++; } return fail != 10; } public static String perHour(int gained, long startTime) { int i = (int)(((double)gained * 3600000D) / (double)(System.currentTimeMillis() - startTime)); return (new StringBuilder()).append(i).toString(); } public static String timeToString(long time) { int seconds = (int)(time / 1000L) % 60; int minutes = (int)((time / 60000L) % 60L); int hours = (int)((time / 0x36ee80L)); return (new StringBuilder(String.valueOf(hours))).append(":").append(minutes).append(":").append(seconds).toString(); } public void walktowell() { RS2Object range = objects.closest(new String[] {"Well"}); status = "Walking to Well"; try { walkTile(new Position (range.getPosition().getX(), range.getPosition().getY(), 0)); } catch (InterruptedException e) { e.printStackTrace(); } } public void bank() { status = "Opening Bank"; RS2Object banks = objects.closest(new String[] {"Bank booth"}); localWalker.walk(banks.getPosition()); while(myPlayer().isMoving()) { } banks.interact("Bank"); } public void withdraw() { status = "Withdrawing"; getBank().depositAll(); getBank().withdraw(1925, 14); getBank().withdraw(434, 14); } public void fill() throws InterruptedException { RS2Object Well = objects.closest(new String[] {"Well"}); status = "Interacting with Well"; getInventory().getItem(1925).interact("Use"); Well.interact("Use"); sleep(1500); } public void soft() throws InterruptedException { status = "Interacting with Clay"; getInventory().getItem(1929).interact("Use"); getInventory().getItem(434).interact("Use"); sleep(900); } public void makeall() { status = "Making X"; if (getInterfaces().getChild(548, 130).isVisible()) { getInterfaces().getChild(309, 2).interact("Make All"); } } public void wersofting() { status = "We Are Softing!"; } private static final Area wellA = new Area(3086,3502,3083,3502); private static final Area bankA = new Area(3091,3449,3098,3494); public int onLoop() throws InterruptedException { if (getColorPicker().isColorAt(573, 133, new Color(175, 176, 162))) { status = "Toggling Run"; interfaces.getChild(548, 94).interact("Toggle Run"); return 500; } if (getBank().isOpen() && getInventory().getAmount(1925,434) == 0) { withdraw(); return 500; } if (bankA.contains(myPlayer())) { walktowell(); return 500; } if (getInventory().getAmount(1761) == 0 && wellA.contains(myPlayer())) { bank(); return 500; } if (getInventory().getAmount(1925,434) == 0) { bank(); return 1500; } if (wellA.contains(myPlayer()) && getInventory().getAmount(1925) != 0 && !myPlayer().isAnimating()) { fill(); return 500; } if (wellA.contains(myPlayer()) && getInventory().getAmount(434) != 0 && !myPlayer().isAnimating()) { soft(); return 800; } if (myPlayer().isAnimating()) { wersofting(); } return 0; } } Link to comment Share on other sites More sharing options...
Apaec Posted January 17, 2015 Share Posted January 17, 2015 Woah My eyes hurt xd (dat code is messy ! ) What exactly is the problem you're having, is it not filling buckets or not softening or not banking or what? Apaec 1 Link to comment Share on other sites More sharing options...
minedas Posted January 17, 2015 Author Share Posted January 17, 2015 (edited) Hi thanks for fast reply.It just stands at well and not fill buckets. Im not really familiar with interacting with inventory items so this is why im used other user script Edited January 17, 2015 by minedas Link to comment Share on other sites More sharing options...
fixthissite Posted January 17, 2015 Share Posted January 17, 2015 (edited) EDIT: Forgot you mentioned there was a problem; my bad. While I look for it, wrap you code in proper code tags to format it, then read what I have below. Does the fill() method get called? As in, is the condition that needs to be true for fill() to execute returning true? Where EXACTLY is the problem? You rarely use String literals. Instead, you create a new StringBuilder for every String you create, even if only appending a single String. Yes, StringBuilders are efficient when needing to concat a ton of Strings, possibly within some kind of loop. But the way you're using them is actually waaaay more costly. You aren't taking advantage of the String pool, which can save you quite a bit of memory, you're creating a bunch of new StringBuilder objects (taking up quite a bit a memory, seeing hoe they contain a String themselves), and performing an un-needed method call (since you could instead just declarw the String you want in StringBuilder's constructor). String literals are your friend. Please do not use a StringBuilder every time you want a String; use a String literal instead. This will first check to see if the String you want already exists in something called a String Pool. If it does, it'll use the pre-existing value, saving you memory. This is a functionality you can only get by using String Literals. If the string doesn't already exist, a new String will be created and added to the pool. This is referred to as "interning", which can be performed manually, although should only be used in special cases. Removing those un-needed StringBuilders will save you some memory. Removing the append and toString methods will save you some processing time Edited January 17, 2015 by fixthissite Link to comment Share on other sites More sharing options...