Everything posted by Explv
- Explv's Scripting 101
-
Explv's OSBot Manager
No, if the script has CLI support you can add the parameters you want to use when you add the Script. Otherwise, leave it blank, and it will start the script as normal Could you show me the error? I will take a look tonight
-
Explv's Scripting 101
Yep, I will add a section on Events
-
Do... While Loops
OP is asking how to use a do while loop to keep reading input from the user, not how to use the MVC pattern with Swing? Seems silly to overcomplicate it with a GUI when OP doesn't even understand loops yet
-
Do... While Loops
You need a do while loop along the lines of "do, get the user's input and change the direction of the robot if the input is valid, while the user's input is not the exit program character" The exit character might be something like ESC
-
Mouse Control Questions
@Page27 If you mean collect mouse data while you play legit, then you could do something like: import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; @ScriptManifest(name = "Mouse Tracker", author = "Explv", info = "", version = 0.1, logo = "") public class MouseExample extends Script { private final List<Point> mouseClickPoints = new ArrayList<>(); private final List<Point> mouseMovedPoints = new ArrayList<>(); @Override public void onStart() { bot.getCanvas().addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { super.mouseClicked(e); mouseClickPoints.add(e.getPoint()); } }); bot.getCanvas().addMouseMotionListener(new MouseAdapter() { @Override public void mouseMoved(MouseEvent e) { super.mouseMoved(e); mouseMovedPoints.add(e.getPoint()); } }); } @Override public int onLoop() throws InterruptedException { return 1000; } @Override public void onExit() { // Output the mouse data } }
-
Mouse Control Questions
Perhaps the Mouse class? And ClientMouseEventHandler
-
Explv's Scripting 101
The thing is, if you knew basic Java, like I state as the prerequisite to this tutorial, you would know that in order to use the methods contained in NPC, GroundItem etc. that are not found in the Entity superclass, then you would use the relevant subclass name when storing the instance. I never mention in this tutorial that you should exclusively use Entity and not the subclass name, I am merely showing the relationship between the different types.
-
Explv's Scripting 101
And why would that be?
-
Explv's Scripting 101
I'll add some more today after work
-
Explv's Scripting 101
Let me know if I have missed anything
- Explv's Scripting 101
-
Explv's Scripting 101
In this case it is primarily for readability purposes, and a habit of mine from working on larger projects with other people.
-
Forum Upgrade
Multiline spoilers seem to be broken:
-
Explv's Scripting 101
Explv's Scripting 101 Prerequisite: basic knowledge of Java 1. Setting up the Java Development Kit and an Integrated Development Environment (IDE) 2. The Script Skeleton 3. Building the script 4. The Script class continued 5. The MethodProvider class, accessing the Inventory, Bank, Player, etc. instances 6. Positions, areas and moving the player 7. Entities (Players, RS2Objects, NPCs and GroundItems) 8. Interactions 9. Sleeping 10. Items and ItemContainers (Inventory, Bank, Equipment, Store, ...) 11. Filtering 12. Widgets 13. Configs 14. Adding a paint 15. Putting it all together, an example script (Smelting iron bars in Al-kharid) 16. Adding a GUI
-
PC benchmarks
http://www.userbenchmark.com/UserRun/2713886
-
Explv's OSBot Manager
I could probably add something to ssh into a VPS and run the commands, i'll see what I can do when I have some free time
-
Parsing valuable drop notification
Agreed, this is over complicated. Either of these options would suffice: Where the message is: String lootMessage = "<col=ef1020>Valuable drop: Onyx (3,038,047 coins)</col>"; Matcher m = Pattern.compile(": (.+) \\(").matcher(lootMessage); if (m.find()) { String loot = m.group(1); } or String loot = lootMessage.substring(lootMessage.indexOf(": ") + 2, lootMessage.lastIndexOf(" ("));
-
Help with enums
I have updated the post where I assume you got this snippet from: http://osbot.org/forum/topic/88389-mining-rocks-with-ore-no-ids/ You can just put the Rock enum in it's own file called Rock.java The usage is also on the thread.
-
Some Java questions
You probably declared your JComboBox like: JComboBox comboBox = new JComboBox(); When it should be: JComboBox<Type> comboBox = new JComboBox<>(); Where "Type" is whatever type script.getTrees() returns
-
Explv's Tutorial Island [Free] [Random Characters]
Are you using the latest version? 5.2?
-
Some Java questions
1. Generally you should try and avoid the use of static unless you are absolutely sure it is correct to use it, and makes sense to use it. A static method belongs to the class and not any instance of the class. It is commonly used for utility methods, another example of it's use would be in the Singleton Pattern. You will find a lot of amateur programmers abusing the static keyword due to their lack of understanding of OOP. 2. You are probably getting this warning because you are using raw types, read a tutorial on Java generics 3. An Enum is a class, it can still have methods etc. It is generally used when you want to specify a fixed list of constants. For example you may have a Tree Enum that specifies a fixed list of Trees someone can choose from in your script. TL;DR Follow some more tutorials and learn some more Java
-
how to filter: walking to npcs only when players arent near them
Optional<NPC> npcOpt = getNpcs().getAll() .stream() .filter(n -> n.getName().equals("NPC Name") && n.getPosition().distance(myPosition()) > 2) .min((n1, n2) -> Integer.compare(n1.getPosition().distance(myPosition()), n2.getPosition().distance(myPosition()))); Explanation: Construct a Stream<NPC> of all the NPCs around the Player Filter the Stream<NPC> so that only the NPCs who's name matches "NPC Name" and is more than two tiles away from the player remain Apply the min function to the Stream<NPC> using a custom comparator that compares distances from the player (essentially returns the closest NPC to the player) Returns an Optional<NPC> With the return value of Optional<NPC>, instead of null checking you do something like: npcOpt.ifPresent(npc -> { }); For more information on the Optional class see https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html For more information on streams see http://www.oracle.com/technetwork/articles/java/ma14-java-se-8-streams-2177646.html and https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html
-
Need some help with my deposit code
getBank().depositAllExcept(item -> item.getName().endsWith(" axe"));
-
Combobox null pointer exception
In this case a JCheckBox would make more sense, however, if you want to use a JComboBox, this works: JComboBox<String> optionSelector = new JComboBox<>(new String[]{ "Yes", "No" }); To check if "Yes" is selected: boolean yesSelected = optionSelector.getSelectedItem().toString().equals("Yes");