-
Posts
1334 -
Joined
-
Last visited
-
Feedback
100%
Everything posted by Twin
-
Console spams all my scripts with the same issue, not sure what's wrong.
Twin replied to Twin's topic in Scripting Help
ahh found the issue, just made a wait case instead of having it return null. Thank you! -
[ERROR][bot #1][02/27 09:44:04 PM]: Error in script executor! java.lang.NullPointerException at BirdHunter.onLoop(BirdHunter.java:43) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ml:189) at java.lang.Thread.run(Unknown Source) is the issue. All my scripts work fine, it's just that gets spammed 24/7 every second. import java.awt.*; 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; import org.osbot.rs07.api.model.GroundItem; @ScriptManifest(author = "twin 763", info = "Crimson Swift Catcher", name = "Crimson Catcher", version = 1, logo = "") public class BirdHunter extends Script { @Override public void onStart() { log("Crimson Hunter by twin 763"); log("Let me know on my forum post any issues you've had"); log("Enjoy the easy levels!"); } Area HUNTING_AREA = new Area(2618,2940,2597,2912); private enum State { LAY, CHECK, PLACE, DROP,DISMANTLE }; private State getState() { Entity snare = objects.closest("Bird snare"); GroundItem snareOnFloor = groundItems.closest("Bird snare"); Entity brokenSnare = objects.closest(9344); if (inventory.isFull()) return State.DROP; if (snareOnFloor != null) return State.LAY; if(snare==null&&snareOnFloor == null&&brokenSnare==null) return State.PLACE; if (snare.hasAction("Check")) return State.CHECK; if(brokenSnare!=null) return State.DISMANTLE; return null; } @Override public int onLoop() throws InterruptedException { if (!HUNTING_AREA.contains(myPlayer())) { log("Returning to Hunting Area"); localWalker.walk(HUNTING_AREA.getRandomPosition(0)); } switch (getState()) { case LAY: GroundItem snareOnFloor = groundItems.closest("Bird snare"); if (snareOnFloor != null) { snareOnFloor.interact("Lay"); sleep(random(2000,3000)); } break; case DROP: inventory.dropAllExcept("Bird snare", "Coins"); break; case PLACE: inventory.interact("Lay","Bird snare" ); sleep(random(2500,3000)); break; case CHECK: Entity snare = objects.closest("Bird snare"); if(snare.hasAction("Check")) snare.interact("Check"); sleep(random(2000,3000)); break; case DISMANTLE: Entity brokenSnare = objects.closest(9344); if(brokenSnare!= null) brokenSnare.interact("Dismantle"); sleep(random(2000,3000)); break; } return random(200, 300); } @Override public void onExit() { log("Thanks for using my script! Report any issues to me on the forum!"); } @Override public void onPaint(Graphics2D g) { } } Everything in there works fine, it's just my console is getting spammed and I can't figure out why.
-
How to have bot pick up birdsnare after a bird has been caught/it fell over
Twin replied to Twin's topic in Scripting Help
did not mean to post here. -
You could maybe get the health of the NPC instead? Like cowHP= NPC.getHealth("Cow"); if(cowHP<8) return State.ATTACK; or something like that. not 100% sure if thats how you do it but something like that might work
-
need help finding a good way to make a if statement to a state more reliable.
Twin replied to Twin's topic in Scripting Help
I'm getting a weird error where smithXP.startTrackingSkills(Skill.SMITHING); is saying that it wants an @ before start and and @ sign instead of a semi colon, other than that everything looks good, Thanks for this by the way! I would have had no clue on how to write a class/method for something like that. -
need help finding a good way to make a if statement to a state more reliable.
Twin replied to Twin's topic in Scripting Help
this post did not show up for me for some reason! did not mean to ignore it. This is exactly what I meant, how would I go about doing that? I make an integer of my smithing experience and then what? kind of lost of what to do there. -
Assume basic quest done i.e monkey madness, lost city, and animal magnetism, a few others but not to important 41 qp total. http://imgur.com/5VcYltL stats, assume anythign crossed out is less than level 10
-
need help finding a good way to make a if statement to a state more reliable.
Twin replied to Twin's topic in Scripting Help
Nope, didn't fix it. Still having the issue where it will use the steel bar on the furnace every 10-20 seconds depending on when the sleep ends. Welp im an idiot lol could have sworn that said isInteracting, well like acted the same way. -
need help finding a good way to make a if statement to a state more reliable.
Twin replied to Twin's topic in Scripting Help
Had no idea getInteracting was a method, that should fix this actually. -
need help finding a good way to make a if statement to a state more reliable.
Twin replied to Twin's topic in Scripting Help
I had animating originally, but the smithing animation stops for about 2 seconds or so inbetween, so it goes back and does it all over again. I'm going to try an idea I had to see if that works i'll report back. -
need help finding a good way to make a if statement to a state more reliable.
Twin replied to Twin's topic in Scripting Help
The one that this thread was about or the if statement in my state? The one my thread is talking is return State.SMITH; the one in the code I linked just breaks after a little bit -
need help finding a good way to make a if statement to a state more reliable.
Twin replied to Twin's topic in Scripting Help
I think I already have that there with the inventory.contains(2353)//2353 is steel bar id When I had it without the cannonballs, it would constantly go back and redo the entire process of selecting the steel bar, furnace, then clicking on steel bars and making all again. and it would do this after every 3 or 4 cannon balls. case SMITH: Entity furnace = objects.closest("Furnace"); sleep(random(1000,2000)); inventory.interact("Use", 2353); sleep(random(500,1000)); furnace.interact("Use"); sleep(random(2000,3000)); if(!inventory.isItemSelected()) { this.interfaces.interactWithChild(309, 2, "Make All"); sleep(random(10000,20000)); break; } that's my smith state if that helps -
My whole script works fine, it's just this if(SMITH.contains(myPlayer())&&inventory.contains(2353)&&!myPlayer().isAnimating()&&!inventory.contains("Cannonball")) everything works all fine and dandy until an event comes in the middle of smithing, because when it goes to dismiss a random event, it will have cannon balls and won't go back to smithing, What would be abetter way to do this.
-
Object is its own thing. An object is something like A tree, ore vein, a door, things like that. A ground item is anything that is on the ground and has orange text.
-
So then it is the main interface is the parent, and the different clickable options are the children? And I'm assuming when you say it's not null, that means the text is black and not red? Thanks for the replies by the way, definatly cleared some confusion up.
-
So would It be something likeEntity furnace = objects.closest("Furnace"); furnace.interact("Smith"); Furnace.interact(Id of option after first click goes here?); So a parent is the main interface, once clicked that becomes the child, and if that's clicked it becomes the grandchild? Will it tell me the ID then of the option I want to click? I was messing around with that yesterday on the spinning wheel and couldn't figure it out
-
So when you click smelt on a furnace, it brings up a bunch of options like bronze, blurite, iron, all of that. How do I have the bot click on one of those, Can't seem to figure it out and have no idea where to look in the api. I thought it might be interfaces but I didn't know what it meant by parent/child.
-
inventory.dropAllExcept(this id, this id, and this id);
-
Currently working on my MLM script, and I wanted to know if there a way to get the closest entity ore vein, and if none are visible have it walk to a different area. I'm assuming this would be an if statement like if(pay==null)//pay being the entity ore vein { getLocalWalker().walk(position for walkinghere); break; } And then have it stop when it gets to the nearest ore vein on the way there. So if it doesn't see an ore vein it will walk to the given point until it sees an ore vein, then move onto the state mine like normal. Would this be the correct way to donit?
-
You'd want something like if(!inventory.isEmpty()){ Bones.interact("Bury"); break; } //then you'd have if(inventory.isEmpty()) { bank.Open; bank.Withdraw(either a string"Bones" or whatever the id of bones are you're using) ;bank.Close(); break; } //this isn't 100% right but it's a start. basically just go into the api, press f3 and search //inventory, then search for a keyword that you //think will help you, and then implement the method //next to inventory so if you want to do something if your inventory is full, inventory.IsFull(); edited something from mobile and it fucked up this things formatting, sorry about that.
-
http://osbot.org/forum/topic/58775-a-beginners-guide-to-writing-osbot-scripts-where-to-get-started-by-apaec/ specifically import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "You", info = "My first script", name = "Tea thiever", version = 0, logo = "") public class main extends Script { @Override public void onStart() { log("Welcome to Simple Tea Thiever by Apaec."); log("If you experience any issues while running this script please report them to me on the forums."); log("Enjoy the script, gain some thieving levels!."); } private enum State { STEAL, DROP, WAIT }; private State getState() { Entity stall = objects.closest("Tea stall"); if (!inventory.isEmpty()) return State.DROP; if (stall != null) return State.STEAL; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case STEAL: Entity stall = objects.closest("Tea stall");//What this does is get's the closest entity //named tea stall, and stores it into stall if (stall != null) {//this if statement is saying if the stall //is not null(exist pretty much) it will interact from it with the option //"Steal-from" stall.interact("Steal-from"); } break;//the break will tell the script to move on to what's //next/go back to find another state case DROP: inventory.dropAll();//if your inventory is not empty, it will //go to this case which basically says it will drop anything in your inventory, one item in your //inventory will trigger this to go off. break; case WAIT: sleep(random(500, 700));//this will happen if your inventory is full, and the stall is //null(nothing on it) break; } return random(200, 300); } @Override public void onExit() { log("Thanks for running my Tea Thiever!"); } @Override public void onPaint(Graphics2D g) { } } This right here is going to be the bear bones to anything you do. You can pretty much write anything using Statements, I'd recommend starting off with a basic script that will power mine/power chop something. Anything that you might need is already a method in the osbot api so you wont need to make your own methods. Do you have knowledge of java itself or have you just wrote a few basic bot scripts before? Commented on some of the code just so you can get a better idea of what it's doing
-
Make a second class and name it Walker, then just copy and paste it. And im not 100% sure since I'm not to familiar with osbot scripting but you might need to do Walker rswalk = new Walker(and then if something goes in here you type it); don't quote me on that though.
-
Need help with banking, bot just goes into bank and stand there
Twin replied to Twin's topic in Scripting Help
Apaec helped me kind of get to know the api and get a start on just general bot scripting, and I used his tea thiever guide to get started so It stemmed form there. What would another way of doing it be? multiple classes?