Jump to content

Chicken Wing

Members
  • Posts

    610
  • Joined

  • Last visited

  • Feedback

    100%

Posts posted by Chicken Wing

  1. How do I make the script change tab by pressing the function keys (e.g. f6 to switch to magic tab)? 

    When I use 

    getKeyboard().typeKey((char) KeyEvent.VK_F6);
    

    It just types "u", if anyone knows what's wrong I would be grateful for some help

     

     

    Edit: nvm I fixed it guy

  2. Yes it is an abstract class, subclassed by concrete classes Objects, NPCS and GroundItems. So you could do objects.get(x,y) or npcs.get(x,y) or groundItems.get(x,y)

     

    Oh I didn't realise it was the parent class (/facepalm), TY!

  3. EntityAPI.get(x,y) returns a list of entities on pos x,y,z with z = myPlayer.getZ()

    !EntityAPI.get(x,y).isEmpty()   --> there is something at position x,y

    EntityAPI is one of npcs, objects, grounditems

     

    This is exactly what I was looking for, thank you QwPha8E.png

     

    EDIT: EntityAPI is an abstract class? So I have to make those methods myself? I think I've found a solution to my problem so its ok now anyway.

     

  4. Refactor node to something like _Node, it's a problem because osbot thinks you're trying to initalise an OSBot node.

    You could also specify it's a core.Node rather than just a Node

     

     

    Refactoring does nothing, as I said the script was working with the exact same code I have right now, I think its some sort of build path error

    Ever try "cleaning" your workspace? Aka deleting all the binaries and recompiling?

     

    Yes, I did that twice, I even deleted the whole project, made a new one and copied over .java files which were uploaded to the sdn

     

     

    EDIT: I FIXED IT, NVM GUYS

  5. Can anyone explain what this stacktrace actually means?

    [ERROR][09/09 05:21:38 PM]: Uncaught exception!
    java.lang.NoSuchMethodError: core.Node.<init>(Lcore/Fletcher;)V
    	at nodes.cut.OpenBank.<init>(OpenBank.java:12)
    	at core.Fletcher.onStart(Fletcher.java:85)
    	at org.osbot.rs07.event.ScriptExecutor.onStart(ni:197)
    	at org.osbot.rs07.event.ScriptExecutor.start(ni:46)
    	at org.osbot.com2.run(dn:246)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    
    

    My script was working fine, and compiles fine, but now even if I make a new project in eclipse and copy over .java files which i know are fine and run the jar I get this error, even when I use the same .java files which are used in the script on the sdn (and the sdn script works). 

  6. Hey, is there a way to select an item in a specific slot in the inventory? I am using :

    sA.inventory.getItemInSlot(14).interact("Use");
    

    to select the 14th unstrung bow, however it just selects the first one (which I understand why). Is there a way to do it without manually defining the area on the screen to click? 

    • Heart 1
  7. new SmartKeyboard(this, 65)
    

    biggrin.png

     

    A few tips would be to use names and not IDs, as well as checking visibility of widgets before you interact with them. Looks solid otherwise, as long as it works!

     

     

    I was having some problems with the default keyboard so I used your one, its very nice smile.png. And yeah thats an oopsy for not checking if its visible. Also if I add paint, and maybe an option to input the string of the log and some other stuff, would this be SDN worthy? (free ofc)

  8. Hey, I've been trying to get familiar with the api and wrote a simple fletching script, it would be great if some more experienced scripters could give some feedback smile.png

    package dev;
    
    import org.osbot.rs07.api.model.Entity;
    import org.osbot.rs07.script.Script;
    import org.osbot.rs07.script.ScriptManifest;
    import org.osbot.rs07.utility.ConditionalSleep;
    
    import util.SmartKeyboard;
    
    import java.awt.*;
    
    @ScriptManifest(author = "You", info = "My first script", name = "Fletcher", version = 0.1, logo = "")
    public class LogCutter extends Script {
    	
    	private boolean _hasKnife = false;
    	private final static int LOG_ID = 1515;
    	private final static int BOW_u_ID = 66;
    
    	@Override
    	public void onStart() {
    		if(inventory.contains(946)){
    			_hasKnife = true;
    		}
    		log("Script started");
    		getMouse().setSpeed(1);
    		
    	}
    
    	private enum State {
    		WITHDRAW_LOGS, CUT_LOGS, WAIT, BANK_BOWS, WITHDRAW_KNIFE, RECOVER_UNEXPECTED_STOP
    	};
    
    	private State getState() {
    		if(!inventory.contains(946)){
    			return State.WITHDRAW_KNIFE;
    		}
    		
    		if(_hasKnife && inventory.isEmptyExcept(946)){
    			return State.WITHDRAW_LOGS;
    		}
    		
    		if(_hasKnife && inventory.getAmount(1515) == 27){
    			return State.CUT_LOGS;
    		}
    		
    		if(_hasKnife && inventory.getAmount(66) == 27){
    			return State.BANK_BOWS;
    		}
    		
    		if(_hasKnife && inventory.contains(LOG_ID) && !myPlayer().isAnimating()){
    			return State.RECOVER_UNEXPECTED_STOP;
    		}
    		
    		return State.WAIT;
    		
    		
    
    	}
    
    	@Override
    	public int onLoop() throws InterruptedException {
    		switch (getState()) {
    		case BANK_BOWS:
    			openBank();
    			depositBows(BOW_u_ID);
    			break;
    			
    		case CUT_LOGS:
    			cutLongBows(LOG_ID);
    			break;
    			
    		case WAIT:
    			break;
    			
    		case WITHDRAW_KNIFE:
    			openBank();
    			withdrawKnife();
    			break;
    			
    		case WITHDRAW_LOGS:
    			openBank();
    			withdrawLogs(LOG_ID);
    			break;
    			
    		case RECOVER_UNEXPECTED_STOP:
    			cutLongBows(LOG_ID);
    			break;
    			
    			
    		}
    
    		return random(200, 300);
    	}
    
    	// private methods -------------------------------------
    
    	private void withdrawLogs(int id) throws InterruptedException {
    		if (this.bank.isOpen() && bank.contains(id)) {
    			bank.withdrawAll(id);
    		}
    		new ConditionalSleep(5000) {
    
    			@Override
    			public boolean condition() throws InterruptedException {
    				return inventory.getAmount(id) == 27;
    			}
    		}.sleep();
    		bank.close();
    		new ConditionalSleep(5000) {
    
    			@Override
    			public boolean condition() throws InterruptedException {
    				return !bank.isOpen();
    			}
    		}.sleep();
    		sleep(random(290, 380));
    		
    	}
    
    	private void withdrawKnife() throws InterruptedException {
    		if (this.bank.isOpen() && bank.contains(946)) {
    			bank.withdraw(946, 1);
    		}
    		new ConditionalSleep(5000) {
    
    			@Override
    			public boolean condition() throws InterruptedException {
    				return inventory.getAmount(946) == 1;
    			}
    		}.sleep();
    		_hasKnife = true;
    		sleep(random(290, 380));
    		
    	}
    
    	private void openBank() throws InterruptedException {
    		if (!this.bank.isOpen()) {
    			Entity bankBooth = objects.closest("Bank booth");
    			if (bankBooth != null) {
    				bankBooth.interact("Bank");
    			}
    			new ConditionalSleep(5000) {
    
    				@Override
    				public boolean condition() throws InterruptedException {
    					return bank.isOpen();
    				}
    			}.sleep();
    		}
    		sleep(random(280, 390));
    		
    	}
    	
    
    	private void depositBows(int id) throws InterruptedException {
    		if (this.bank.isOpen() && bank.contains(id)) {
    			bank.depositAll(id);
    		}
    		new ConditionalSleep(5000) {
    
    			@Override
    			public boolean condition() throws InterruptedException {
    				return inventory.getAmount(id) == 0;
    			}
    		}.sleep();
    		sleep(random(290, 380));
    		
    	}
    	
    	private void cutLongBows(int id) throws InterruptedException {
    		if(inventory.contains(id)){
    			inventory.getItem(946).interact("Use");
    			new ConditionalSleep(5000) {
    
    				@Override
    				public boolean condition() throws InterruptedException {
    					return inventory.isItemSelected();
    				}
    			}.sleep();
    			
    			inventory.interact("Use", id);
    			
    			new ConditionalSleep(5000) {
    
    				@Override
    				public boolean condition() throws InterruptedException {
    					return dialogues.isPendingOption();
    				}
    			}.sleep();
    			
    			sleep(random(280, 390));
    			widgets.get(304, 10).interact("Make X");
    			sleep(random(400, 700));
    			new SmartKeyboard(this, 65).typeString("33", true, false);
    			sleep(random(280, 390));
    			getMouse().moveOutsideScreen();
    			new ConditionalSleep(100000) {
    
    				@Override
    				public boolean condition() throws InterruptedException {
    					return inventory.getAmount(BOW_u_ID) == 27;
    				}
    			}.sleep();
    			sleep(random(280, 390));
    		}
    		
    	}
    	
    	//  ---------------------------------------------------------------------------
    
    	@Override
    	public void onExit() {
    		log("Script stopped");
    	}
    
    	@Override
    	public void onPaint(Graphics2D g) {
    
    	}
    
    }
    
×
×
  • Create New...