mitsuki Posted September 1, 2018 Share Posted September 1, 2018 3 hours ago, Apaec said: Fishing spots may be a little odd - use the entity debugger to see if they are objects or NPCs. They could well be NPCs, in which case getObject() won't work! -Apa Holy shit dude, thanks a lot, i completely forgot about using the debugger! Now it is finally working, and i'm trying different ways of using the api My final question is how do i add a check within the script to check if the inventory is full before dropping the shrimp? Would it be (taking into account that the net is one inventory space) : if (getInventory().contains("Raw shrimps") 27) or if (getInventory() == 28) Are you into cryptocurrency? I can send you some as a thank you for all the help on starting me off with scripting Quote Link to comment Share on other sites More sharing options...
Apaec Posted September 2, 2018 Author Share Posted September 2, 2018 19 hours ago, mitsuki said: Holy shit dude, thanks a lot, i completely forgot about using the debugger! Now it is finally working, and i'm trying different ways of using the api My final question is how do i add a check within the script to check if the inventory is full before dropping the shrimp? Would it be (taking into account that the net is one inventory space) : if (getInventory().contains("Raw shrimps") 27) or if (getInventory() == 28) Are you into cryptocurrency? I can send you some as a thank you for all the help on starting me off with scripting Glad you got it working! Try: getInventory().isFull() Also, you might find getInventory().isEmpty() useful at some point as well --Apa Quote Link to comment Share on other sites More sharing options...
mitsuki Posted September 2, 2018 Share Posted September 2, 2018 I'm trying to get the paint to count the xp and time how long the script has been running. Every time a shrimp is caught, the counter shows 10xp for a second or 2, then goes back to 0. The timer doesn't work at all for some reason. Any advice? I have a feeling that the xp counter is due to it being before the return random event. Do i need to make a new public method for the xp tracker? Spoiler DECLARED BEFORE ON START: public Timer timer; END OF THE MAIN LOOP: getExperienceTracker().start(Skill.FISHING); timer = new Timer(); return random(2000, 2500); PAINT: @Override public void onPaint(Graphics2D g) { g.drawString("Mitsuki's AutoFisher", 10, 295); g.drawString("Fishing XP: " + ( getExperienceTracker()).getGainedXP(Skill.FISHING) + "(" + getExperienceTracker().getGainedXPPerHour(Skill.FISHING) + ")", 10, 319); g.drawString("Time Running: " + (timer) , 10, 331); } Quote Link to comment Share on other sites More sharing options...
mitsuki Posted September 2, 2018 Share Posted September 2, 2018 And thank you for all the help dude! Quote Link to comment Share on other sites More sharing options...
Apaec Posted September 3, 2018 Author Share Posted September 3, 2018 On 9/2/2018 at 6:45 PM, mitsuki said: I'm trying to get the paint to count the xp and time how long the script has been running. Every time a shrimp is caught, the counter shows 10xp for a second or 2, then goes back to 0. The timer doesn't work at all for some reason. Any advice? I have a feeling that the xp counter is due to it being before the return random event. Do i need to make a new public method for the xp tracker? Hide contents DECLARED BEFORE ON START: public Timer timer; END OF THE MAIN LOOP: getExperienceTracker().start(Skill.FISHING); timer = new Timer(); return random(2000, 2500); PAINT: @Override public void onPaint(Graphics2D g) { g.drawString("Mitsuki's AutoFisher", 10, 295); g.drawString("Fishing XP: " + ( getExperienceTracker()).getGainedXP(Skill.FISHING) + "(" + getExperienceTracker().getGainedXPPerHour(Skill.FISHING) + ")", 10, 319); g.drawString("Time Running: " + (timer) , 10, 331); } The reason for your problem is that you're resetting the experience tracker every loop. It would make sense that it's going back to zero . You want to start the experience tracker in your onStart rather than in your onLoop. As for the timer, you're creating a new object instance every onLoop and i'm not sure why, but it's pretty much the same reasoning as your exp tracker issue. Put it in the onStart also. I'm not sure if your timer class has a suitable toString() method but if it doesn't then the timer will not draw what you expect to the canvas. You might have to look into some string formatting stuff to get that to work if it isn't working already No worries for the help, but in future please post all of your code as issues could hide in the bits which you don't post. GL! Apa Quote Link to comment Share on other sites More sharing options...
GeeOhB Posted September 5, 2018 Share Posted September 5, 2018 (edited) Hey man appreciate the effort that's in this post. I'm trying to follow the tutorial but use it to cut down trees instead of thieving stalls. Here's the code: Quote package Woodcutter; import java.awt.Graphics2D; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "GeeOhB", info = "My first script", name = "Woodcutter", version = 0, logo = "") public class Woodcutter extends Script { @Override public void onStart() { log("Let's CHOP BABY"); } @Override public int onLoop() throws InterruptedException { RS2Object tree = getObjects().closest("Tree"); if (tree != null) { tree.interact("Chop-down"); } return random(200, 300); } @Override public void onExit() { log("Thanks for running my Woodcutter!"); } @Override public void onPaint(Graphics2D g) { } } When I run the script it just mouses over the nearest tree but doesn't interact. It just sits idle on the tree, occasionally mousing over to a different one if it deems it nearer. When I hover over .interact on Eclipse it gives me this error: Quote boolean org.osbot.rs07.api.model.Interactable.interact(String... arg0) Note: This element has no attached Javadoc and the Javadoc could not be found in the attached source. All google can tell me is the .Jar file isn't found and to try re-attaching it. But I have attached it over and over, in as many ways possible. OSbot.JAr (latest version) is in the referenced libraries, etc. I've got it in multiple different folders including the one I'm working in and it still doesn't work. Any Ideas? EDIT: OK forget my question. I cleaned my hard drives, recovered windows, cleared all my crap. Re-installed everything needed and now it's working. I also had issues with this error after the reinstall: "the type org.osbotlp2 cannot be resolved. it is indirectly referenced from .class files" I was trying to use Eclipse and osBot on a different Hard drive than :/C. I was using it on :/E (I have multiple). This threw up alot of unexpected errors, Java not communicating and shit. I'm keeping everything on my :/C drive now and it's working fine. Continuing the tutorial now! Edited September 7, 2018 by GeeOhB Solved my problems Quote Link to comment Share on other sites More sharing options...
Apaec Posted September 8, 2018 Author Share Posted September 8, 2018 On 9/5/2018 at 10:04 PM, GeeOhB said: Hey man appreciate the effort that's in this post. I'm trying to follow the tutorial but use it to cut down trees instead of thieving stalls. Here's the code: When I run the script it just mouses over the nearest tree but doesn't interact. It just sits idle on the tree, occasionally mousing over to a different one if it deems it nearer. When I hover over .interact on Eclipse it gives me this error: All google can tell me is the .Jar file isn't found and to try re-attaching it. But I have attached it over and over, in as many ways possible. OSbot.JAr (latest version) is in the referenced libraries, etc. I've got it in multiple different folders including the one I'm working in and it still doesn't work. Any Ideas? EDIT: OK forget my question. I cleaned my hard drives, recovered windows, cleared all my crap. Re-installed everything needed and now it's working. I also had issues with this error after the reinstall: "the type org.osbotlp2 cannot be resolved. it is indirectly referenced from .class files" I was trying to use Eclipse and osBot on a different Hard drive than :/C. I was using it on :/E (I have multiple). This threw up alot of unexpected errors, Java not communicating and shit. I'm keeping everything on my :/C drive now and it's working fine. Continuing the tutorial now! Hmm, odd issues but i'm glad to hear that you got it all sorted Let me know if you have any further problems in the future Apa Quote Link to comment Share on other sites More sharing options...
GeeOhB Posted September 10, 2018 Share Posted September 10, 2018 (edited) I appreciate the replies dude, you are super helpful. So, I've got everything set up now. I'm trying to make a simple looting script. I think i;m getting there. I've read a few things. So far this is my code: Quote package Looter; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "GeeOhB", name = "WildyLooter", info = "Loot dem addy arrows", version = 0.1, logo = "") public final class Looter extends Script { public final int onLoop() throws InterruptedException { if (!inCombat()) { loot(); } else { run(); } return 0; } public void loot() { Entity arrow = getGroundItems().closest("Adamant arrow"); arrow.interact("take"); } public void run() { getSettings().setRunning(true); getWalking().webWalk(Banks.EDGEVILLE); } public boolean inCombat() { return getCombat().isFighting(); } } It picks up addy arrows (spam clicks). I'm currently trying to get it to run away if it's in combat. Basically: If it's not in combat - pick up arrows - else - run away. I've set it to run to Edgeville bank(hopefully?). But every time it gets in combat it's still running around spam clicking arrows. It doesn't run away. Any pointers for me? Edited September 10, 2018 by GeeOhB Quote Link to comment Share on other sites More sharing options...
Apaec Posted September 10, 2018 Author Share Posted September 10, 2018 32 minutes ago, GeeOhB said: I appreciate the replies dude, you are super helpful. So, I've got everything set up now. I'm trying to make a simple looting script. I think i;m getting there. I've read a few things. So far this is my code: It picks up addy arrows (spam clicks). I'm currently trying to get it to run away if it's in combat. Basically: If it's not in combat - pick up arrows - else - run away. I've set it to run to Edgeville bank(hopefully?). But every time it gets in combat it's still running around spam clicking arrows. It doesn't run away. Any pointers for me? Firstly, i'd make sure that you're properly null-checking the arrows before trying to pick them up. You're probably getting a ton of errors in your console at the moment, or would do if there were no addy arrows around. Secondly, perhaps try changing your inCombat() method. You're currently checking if you're fighting, which is when you are attacking someone else. This is not what you want. Instead, perhaps try myPlayer().isUnderAttack() Good luck Apa Quote Link to comment Share on other sites More sharing options...
GeeOhB Posted September 10, 2018 Share Posted September 10, 2018 Ahhh I see, cool! Thanks for the help dude, appreciated. 1 Quote Link to comment Share on other sites More sharing options...
mitsuki Posted September 20, 2018 Share Posted September 20, 2018 On 9/3/2018 at 8:30 PM, Apaec said: The reason for your problem is that you're resetting the experience tracker every loop. It would make sense that it's going back to zero . You want to start the experience tracker in your onStart rather than in your onLoop. As for the timer, you're creating a new object instance every onLoop and i'm not sure why, but it's pretty much the same reasoning as your exp tracker issue. Put it in the onStart also. I'm not sure if your timer class has a suitable toString() method but if it doesn't then the timer will not draw what you expect to the canvas. You might have to look into some string formatting stuff to get that to work if it isn't working already No worries for the help, but in future please post all of your code as issues could hide in the bits which you don't post. GL! Apa Thank you dude! Quote Link to comment Share on other sites More sharing options...
Glaciation96 Posted September 23, 2018 Share Posted September 23, 2018 (edited) Hey there, great to see that people are actually willing to help scrubs like us with scripting! I'm really trying to get into javascript and thought this would be an awesome place to get a foothold onto things. Below is my script, I've not tested it yet, but naturally I'd expect that many things are missing. To begin, I'm trying to create a simple karamaja fishing script that banks at the deposit box. I've looked around and this is what I was able to write up. Would it be too much to ask for an explanation on how or even where to begin with making trips to the main land, speaking to the ferry people and coming back? If not, I would really appreciate if someone could direct me to an area of scripting to learn first as a prerequisite to what I'm trying to achieve. My script doesn't properly check if the inv is full before fishing I know, but there isn't much point in adding that now since even if it is full, I've no idea how to make the bot bank the dank. Spoiler package rsLobstersPack; import java.awt.Graphics2D; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.utility.ConditionalSleep; //not used here but really trying to look into this import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Glaciation96", info = "First Attempt", name = "KaramajaLobs", version = 0, logo = "") public class Klobsters extends Script { private NPC fishingSpot; @Override public void onStart() { log("Let's get started!"); } @Override public int onLoop() throws InterruptedException { fishingSpot = this.getNpcs().closest("Fishing Spot"); if (getInventory().contains("Lobster")) { getInventory().drop("Lobster"); //For the above, I'd much prefer to bank but that's well too complicated for now... } else if (fishingSpot != null && fishingSpot.exists() && !myPlayer().isAnimating()) { fishingSpot.interact("Cage"); } return random(200, 300); } /* public int onLoop() throws InterruptedException { RS2Object stall = getObjects().closest("Tea Stall"); if (getInventory().contains("Cup of tea")) { getInventory().drop("Cup of tea"); } else if (stall != null && !myPlayer().isAnimating()) { stall.interact("Steal-from"); } return random(200, 300); } */ @Override public void onExit() { log("Doubt it worked..."); } @Override public void onPaint(Graphics2D g) { } } Thanks a bunch. Edited September 23, 2018 by Glaciation96 Quote Link to comment Share on other sites More sharing options...
Apaec Posted September 23, 2018 Author Share Posted September 23, 2018 14 minutes ago, Glaciation96 said: Hey there, great to see that people are actually willing to help scrubs like us with scripting! I'm really trying to get into javascript and thought this would be an awesome place to get a foothold onto things. Below is my script, I've not tested it yet, but naturally I'd expect that many things are missing. To begin, I'm trying to create a simple karamaja fishing script that banks at the deposit box. I've looked around and this is what I was able to write up. Would it be too much to ask for an explanation on how or even where to begin with making trips to the main land, speaking to the ferry people and coming back? My script doesn't properly check if the inv is full before fishing I know, but there isn't much point in adding that now since even if it is full, I've no idea how to make the bot bank the dank. Reveal hidden contents package rsLobstersPack; import java.awt.Graphics2D; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.utility.ConditionalSleep; //not used here but really trying to look into this import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Glaciation96", info = "First Attempt", name = "KaramajaLobs", version = 0, logo = "") public class Klobsters extends Script { private NPC fishingSpot; @Override public void onStart() { log("Let's get started!"); } @Override public int onLoop() throws InterruptedException { fishingSpot = this.getNpcs().closest("Fishing Spot"); if (getInventory().contains("Lobster")) { getInventory().drop("Lobster"); //For the above, I'd much prefer to bank but that's well too complicated for now... } else if (fishingSpot != null && fishingSpot.exists() && !myPlayer().isAnimating()) { fishingSpot.interact("Cage"); } return random(200, 300); } /* public int onLoop() throws InterruptedException { RS2Object stall = getObjects().closest("Tea Stall"); if (getInventory().contains("Cup of tea")) { getInventory().drop("Cup of tea"); } else if (stall != null && !myPlayer().isAnimating()) { stall.interact("Steal-from"); } return random(200, 300); } */ @Override public void onExit() { log("Doubt it worked..."); } @Override public void onPaint(Graphics2D g) { } } Thanks a bunch. Hey, Firstly, we're working with Java here, not javascript! They're entirely different Your script looks good so far, well done. As for banking, take it one step at a time. First, make the script walk to the ferry people. Initially you can use the webwalker while you sort out the logic of your script, but after that I would strongly recommend using pathwalking as you know both your source and destination. You can learn more about the functionality of these from the OSBot API After you've got walking done, you need to interact with the ferry dude. I'm not sure how this works - maybe there are dialogues which you have to navigate, in which case you will need the dialogue API. You might not have to deal with dialogues at all however, this depends on the interaction process. Interact with the ferry dude much like you do with the fishing spot! I've left my reply quite open ended as the best way to learn is through trying. You can perhaps ask more detailed questions here if you need more help, or alternatively ask people directly in the OSBot chatbox or the OSBot discord. Good luck! Apa Quote Link to comment Share on other sites More sharing options...
Glaciation96 Posted September 23, 2018 Share Posted September 23, 2018 Thanks a bunch! Yes, I've just realised that what I was asking for was well too broad, making it difficult for people to answer without taking up hours lol. I'll definitely look more into this and will be back with more specific questions. Quote Link to comment Share on other sites More sharing options...
Glaciation96 Posted September 26, 2018 Share Posted September 26, 2018 (edited) List<Position> myPositionName = new ArrayList<>(); Position[] lobSpotToPos1 = { new Position(2922,3166,0), new Position(2915,3153,0) }; Position[] lobSpotToPos2 = { new Position(0,0,0), new Position(1,1,1) }; Position[] lobSpotToPos3 = { new Position(0,0,0), new Position(1,1,1) }; Position[] lobSpotToPos4 = { new Position(0,0,0), new Position(1,1,1) }; getWalking().walkPath(Arrays.asList(lobSpotToPos1)); I've been doing some research into arrays and the fundamentals of how to write out code correctly, or try to... If I wanted to have multiple paths, then to call them whenever I see fit, I would have something similar to the above right? But when I type this into Eclipse, it's saying 'Arrays cannot be resolved' on the 'getWalking...' line of code when I try to call it. What am I doing wrong? Could it be a syntax fail? Also, I have another question, assuming that the code was able to run and I chose the journey 'lobSpotToPos1' would the bot be selecting those exact tiles via the map, traversing in chronological order until it reaches the ferrymen? Or do the tiles need to be visible within the game window... Thanks! Edited September 26, 2018 by Glaciation96 Quote Link to comment Share on other sites More sharing options...