Jump to content

Beginner noob problems


HastyLife

Recommended Posts

Heya I just wanted to ask how I could make it that my Player does stop if he interact with the Rock (mining) I could put sleeping on like 10 secs but I want to that he not waits 10 sec even he mined the rock after 2 secs.

 

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;
 
@ScriptManifest(author = "Someone", info = "Testing", name = "Mining Test", logo = "", version = 0)
public class main extends Script {
 
public void onStart() {
log("Shitty test");
}
 
private enum State {
MINE, DROP, WAIT
};
            
private State getState() throws InterruptedException {
Entity stall = objects.closest("Rocks");
        inventory.dropAllExcept(1265);
        sleep(random(1000));
if (stall != null)
return State.MINE;
return State.WAIT;
}
 
public int onLoop() throws InterruptedException {
switch (getState()) {
case MINE:
Entity stall = objects.closest("Rocks");
if (stall != null) {
stall.interact("Mine");
}
break;
case DROP:
inventory.dropAll();
break;
case WAIT:
sleep(random(500, 700));
break;
}
return random(200, 300);
}
 
public void onExit() {
log("Test more");
}
 
public void onPaint(Graphics2D g) {
 
}
 
}
 
 
Thanks for any help.
~Life
Link to comment
Share on other sites

Vilius answered your question really well, but as a side note, you might want to have a look into condition sleeping. It can be very useful. 

 

For instance, say you want to drop everything except for a certain ore, you could write:

if(inventory.isFull()) {
      inventory.dropAllExcept(2958);
      new ConditionalSleep(10000) {
	    @[member=Override]
						
	    public boolean condition() throws InterruptedException {
			return inventory.onlyContains(2958);
			}
	    }.sleep();
}

This would, if your inventory is full, drop everything except for item ID 2958, and sleep until your inventory only contains item ID 2958.

 

If after 10000 ms your inventory still does not only contain 2958 (if the script failed to drop something for some reason), it will repeat, trying to drop everything and sleeping until the condition of "inventory.onlyContains(2958)" is met.

 

  • Like 1
Link to comment
Share on other sites

Vilius answered your question really well, but as a side note, you might want to have a look into condition sleeping. It can be very useful. 

 

For instance, say you want to drop everything except for a certain ore, you could write:

if(inventory.isFull()) {
      inventory.dropAllExcept(2958);
      new ConditionalSleep(10000) {
	    @[member='Override']
						
	    public boolean condition() throws InterruptedException {
			return inventory.onlyContains(2958);
			}
	    }.sleep();
}

This would, if your inventory is full, drop everything except for item ID 2958, and sleep until your inventory only contains item ID 2958.

 

If after 10000 ms your inventory still does not only contain 2958 (if the script failed to drop something for some reason), it will repeat, trying to drop everything and sleeping until the condition of "inventory.onlyContains(2958)" is met.

Okay cool  I understand thanks!

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...