Everything posted by Explv
-
Script laggs.
You should probably learn what that means..
-
Never really coded in java, where to start
The simplest way to open a bank without spam clicking is using the following method: public void openBank() throws InterruptedException{ getBank().open(); // Open the bank new ConditionalSleep(5000) { // Sleep until the bank is open, or for 5 seconds @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); } The same logic can be applied to many different tasks in scripts. For example, if you wanted to chop down a tree, to prevent spam clicking you could do something like: @Override public int onLoop throws InterruptedException { if(!myPlayer().isAnimating()){ chopDownTree(); // Chop down a tree if we're not animating } return random(200, 300); } private void chopDownTree(){ RS2Object tree = S.getObjects().closest("Tree"); if(tree != null){ tree.interact("Chop down"); // Chop down the tree new ConditionalSleep(5000) { // Sleep until the player is animating, or for 5 seconds @Override public boolean condition() throws InterruptedException { return S.myPlayer().isAnimating(); } }.sleep(); } }
-
Explv's Walker
Yeah I know, I have pushed a solution to the SDN, just waiting for the SDN to be updated. Problem is the bugs aren't reproducible on my local version. They only occur on the SDN :P
-
Never really coded in java, where to start
There are plenty of Java tutorials on the internet. Once you are familiar with Java read the scripting tutorials in the Scripting help section, and check out the API which can be found in the navigation bar above.
-
Explv's Walker
The SDN hasn't been updated yet....
-
Check runes for magic spell
It will most likely be based on the widgets in the spell tab. The spells will have different widget values when they are highlighted (can cast) and when they are not. Therefore using this method you need to change to the spell tab to check it. The only other alternative is to check your supplies in the inventory & equipment.
-
Check runes for magic spell
Check if your inventory contains the runes... private boolean canTeleportToVarrock(){ return getInventory().contains("Fire rune") && getInventory().contains("Law rune") && getInventory().getAmount("Air rune") >= 3; }
-
Explv's Walker
I have been busy at work... I will take a look at it this weekend. Please be patient Edit: Issue should be resolved. The script should work once the SDN is updated.
-
Explv's Walker
- Obfuscating your local scripts
You missed out your username from the config path. You put @c:\Users\Desktop\... rather than @C:\Users\Cody\Desktop\... Also in the .pro file where you have put package.Core that should be replaced with your package name. If your main script file Core is not in a package, just put -keep public class Core- Explv's Walker
- 2 questions
There is a new walking method too you know: walking.walk(position); And its probably an issue with your Script, not the OSBot API- Anyone here hold jobs?
Nope, studied CS, currently working as a Software Engineer.- Anyone here hold jobs?
Software Engineer- Obfuscating your local scripts
- Bot isn't walking
Or you can just do private final Area LUMBRIDGE_BANK = new Area(new Position(3205, 3208, 2), new Position(3216, 3229, 2));- Walk to a random tile inside an area?
This code wont make any difference. Considering his walking code will be inside the onLoop method, the same functionality will occur. The issue lies somewhere else, probably with the walker stopping outside the area due to its minThreshold setting.- Obfuscating your local scripts
Missed a line out: -keepattributes *Annotation* Which is essential, because you need to keep the @ScriptManifest annotation. I have edited the config.- Obfuscating your local scripts
Maybe not for you, but some people asked me to make it, and some people don't know how to do it- Obfuscating your local scripts
- Obfuscating your local scripts
As some people do not know how to do this, and it is useful to prevent people stealing your code, here is how to obfuscate (https://en.wikipedia.org/wiki/Obfuscation) using ProGuard. If you don't know what Obfuscation looks like, here is an example of one of my classes, post obfuscation: 1. Download and extract proguard http://sourceforge.net/projects/proguard/files/ 2. Create a folder anywhere called "proguard_configs", this is where you will store your configuration files to be used with ProGuard. 3. In the proguard_configs folder, create a new empty proguard config file (.pro) in notepad. 4. Define your configuration, here is the configuration I use for my scripts: -injars C:\Users\Username\OSBot\Scripts\script.jar -outjars C:\Users\Username\Obfuscated\script_obf.jar -libraryjars C:\Users\USername\Downloads\OSBot 2.4.29.jar -libraryjars C:\Program Files\Java\jre1.8.0_66\lib\rt.jar -keepattributes *Annotation* -keep public class package.Main -injars is file path to the script .jar to be obfuscated -outjars is the file path to the obfuscated script .jar -libraryjars are the OSBot.jar and the Java runtime rt.jar -keepattributes *Annotation* ensures that we keep the @ScriptManifest annotation Finally we specifiy that we want to keep the main Script class, as we need this as the entry point to our script. You should replace "package.Main" with the package that your script is in, and the name of your main script file 5. Finally run the following command in cmd / terminal, replacing path_to_proguard with the path to proguard.jar, which is found in the proguard\lib folder, and path_to_config with the path to the .pro file you previously made: java -jar path_to_proguard.jar @path_to_config.pro 6. Note if you get warnings about missing classes, that are not classes you have defined, add to you config the line, replacing javafx with the package name: -dontwarn javafx.**- SRSYL wtf JFormDesigner
You should place the image inside of a folder called "resources". This folder should be placed within src You then load the image using: private void initComponents() { Image image = getImage("title.png"); if(image != null) label1.setIcon(new ImageIcon(image)); } private Image getImage(String imageName){ try{ return ImageIO.read(TutorialIsland.class.getResourceAsStream("/resources/" + imageName)); } catch(IOException e){ } return null; }- clicking issues
I have rewritten it slightly. I put the onLoop code inside if(!myPlayer().isAnimating()) so that it will not click the Tea stall if it is already thieving. Then I added a ConditionalSleep after the interaction, which stops sleeping when the player has begun animating. (untested) 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; @ScriptManifest(author = "You", info = "My first script", name = "Tea thiever", version = 1.0, logo = "") public class TeaStealer extends Script { private enum State { STEAL, DROP } @Override public int onLoop() throws InterruptedException { if(!myPlayer().isAnimating()) { switch (getState()) { case STEAL: steal(); break; case DROP: drop(); break; } } return random(200, 300); } private State getState() { if(getInventory().isFull()) return State.DROP; return State.STEAL; } private void steal(){ Entity stall = getObjects().closest("Tea stall"); if (stall != null) { stall.interact("Steal-from"); new ConditionalSleep(2000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } } private void drop(){ getInventory().dropAll(); } }- SRSYL wtf JFormDesigner
Works fine for me when I run it (not on OSBot): The only thing I had to remove was: label1.setIcon(new ImageIcon(getClass().getResource("/title.png")); because I don't have the image obviously. Perhaps you are getting an NPE because one of the image locations is wrong- doorHandler not behaving as expected
import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.utility.ConditionalSleep; public class DoorHelper { private final Script S; public DoorHelper(final Script S){ this.S = S; } public RS2Object getDoor(Area doorArea){ //noinspection unchecked return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj)); } public boolean doorIsClosed(RS2Object door){ return door.hasAction("Open"); } public void openDoor(Area doorArea){ RS2Object door = getDoor(doorArea); if(door != null && doorIsClosed(door)){ door.interact("Open"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return !doorIsClosed(getDoor(doorArea)); } }.sleep(); } } } - Obfuscating your local scripts