Jump to content

Purple

Members
  • Posts

    508
  • Joined

  • Last visited

  • Days Won

    1
  • Feedback

    100%

Purple last won the day on December 13 2013

Purple had the most liked content!

Profile Information

  • Gender
    Male
  • Location:
    Falador

Recent Profile Visitors

3233 profile views

Purple's Achievements

Mithril Poster

Mithril Poster (6/10)

195

Reputation

3

Community Answers

  1. Purple

    46-53 thieving.

    uh I can bot it for you if you want lol i have a private sorc script
  2. DDDDDDDISSSSSSSSORRRRRRRRRRRD FUCKIN SUCKS DOOOOD

    1. Purple

      Purple

      I'm sorry pa

  3. Purple

    more at 9

     

  4. Just cache inventory before making a call to loot and check in a sleep condition if the size or count of the inventory has been updated or make an inventory listener.
  5. If you have web development knowledge, then scripting should be really easy for you pick up. Firstly, you want to pick out an IDE; IntelliJ, Eclipse Once you've installed Java JDK 8.0+, open up your IDE and create a new project. For now you should ignore basic scripting and learn to do simple tasks in raw java such as; hello world, printing data types and objects, understanding of methods and their return types, parameters, fields, and constructors, and most importantly, understanding object references in memory. Once you're able to make a basic java application that can successfully use the core basics of Java, only then should you attempt to make a basic script. Understanding object references and their return types is going to save you a lot of headache when you're first starting to script. keywords primitive data types method structure parameters fields constructors That's just to scratch the surface, but you can write a basic script with only knowledge of keywords, primitives, and method structure. The rest is only needed for more complex scripts. If you're a visual learner, then I suggest watching Bucky's Java tutorial series on YouTube up to at least video 35 for a good grasp on how to make an intermediate script. Good luck
  6. You're right, but we're talking about nano seconds here :P It's not going to make a difference when it comes to RuneScape scripting. However, streams are a little bit slower than iterating over a collection using an iterator, but I'd rather have functionality and clarity of minimal performance when it comes to writing scripts. Some value speed over quality of life. Nice point out though.
  7. You have to compile it and save it to your scripts folder located in C:\Users\YOUR_NAME_HERE\OSBot\Scripts
  8. Introduction To Predicates What is a Predicate in Java 8? A predicate is a boolean-valued function. In Java 8, it's used primarily for it's functional properties as well as it's ability to result in a true or false statement. This is really useful when you need to filter collections without having to loop over a collection manually as the stream api allows you to also chain predicates. P: X→ {true, false} P being the predicate (value or reference passed in) and X represents the following truth statement resulting in true or false. This might be confusing at first, but I'll show examples later on how this makes sense and why you should use this over the commonly used Filter<T> in OSBot. How is this any better than OSBot's Filter<T> api? We can use predicates to chain logic expressions and filter as many conditions as me need to while keeping our logic nice and clean. We can combine two pedicates where we filter a collection where both condition are met or return the second if the first predicate returns false. Collection of Loaded NPS List<NPC> where we'll be performing our filter final List<NPC> loaded = getNpcs().getAll(); create a list of all loaded npcs in the area Simple Predicate Filtering A Predicate final Predicate<NPC> exists = npc -> npc.exists(); This creates a predicate with the truth statement P(npc) : return true if npc exist Using it inside a stream to filter a collection final NPC getNpcWhere = loaded.stream().filter(exists).findFirst().orElse(null) This will return the first match in the collection that matches the predicate truth statement that returned true or else returns a null NPC object. Chaining Predicates Two Predicates we're going to chain final Predicate<NPC> exists = npc -> npc.exists(); final Predicate<NPC> isAttackable = npc -> npc.exists() && npc.hasAction("Attack") && !npc.isUnderAttack(); Predicate Chain were 2 Predicates return true final NPC getNpcWhere = loaded.stream().filter(exists.and(isAttackable)).findFirst().orElse(null); Here, we're simply chaining preidicates. We're filtering the collection where the the npc exists and it's attackable and if both This or That Predicates Three Predicates we're going to chain final Predicate<NPC> exists = npc -> npc.exists(); final Predicate<NPC> isInteractingLocally = npc -> npc.isInteracting(getPlayers().myPlayer()); final Predicate<NPC> isAttackable = npc -> npc.exists() && npc.hasAction("Attack") && !npc.isUnderAttack(); Alright, this is where the magic happens in a combat script! We can create 1 predicate query that should always return true then either return the second one or the third depending on the second returns true or not. The logic behind this one is that in a combat script, you'd obviously want to return npcs attacking you before you attack a random npc right? So you can achieve this by doing a predicate or function. final NPC getNpcWhere = loaded.stream().filter(exists.and(isInteractingLocally.or(isAttackable))).findFirst().orElse(null); We just made a really advanced logic filter in 1 line of code! That's the power of using Predicates over a generic Filter<T>
  9. Changes your OSBot frame title to show your current IP address of your bot. Source import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import javax.swing.*; import java.awt.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; @ScriptManifest(author = "Purple", name = "IP Display Changer", version = 1.01, info = "Changes the title of your osbot to display your bots IP address.", logo = "") public class Display extends Script { @Override public int onLoop() throws InterruptedException { changeFrameTitle("OSBot (" + getCurrentIPAddress() + ")"); stop(false); return 0; } public void changeFrameTitle(final String title) { for(Frame frame : Frame.getFrames()) { if(frame.isVisible() && frame.getTitle().startsWith("OSBot")) { SwingUtilities.invokeLater(() -> frame.setTitle(title)); break; } } } public String getCurrentIPAddress() { try { URL url = new URL("http://myip.dnsomatic.com/"); BufferedReader b = new BufferedReader(new InputStreamReader(url.openStream())); String ip = b.readLine(); b.close(); return ip; } catch (Exception e) { e.printStackTrace(); } return "null"; } }
  10. I can make a script to do this is you guys want with maybe whatever title you want + theme Edit: better image
×
×
  • Create New...