-
Posts
508 -
Joined
-
Last visited
-
Days Won
1 -
Feedback
100%
Posts posted by Purple
-
-
uh I can bot it for you if you want lol i have a private sorc script
-
The hero we need
- 1
-
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.
- 3
-
VIP+ Users
-
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.
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
- 1
-
You didn't mention anything about execution time, you think it will be faster then a regular Filter?
Khaleesi
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.
- 1
-
where do i have to safe this ?
You have to compile it and save it to your scripts folder located in
C:\Users\YOUR_NAME_HERE\OSBot\Scripts
-
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
-
top par
-
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"; } }
- 9
-
This would be excellent, theres already a script from projectpat that you can look into the ip your using.
But it would be great if it would show instead of you have to open up a script.
Regardless you still have to run a script
-
I can make a script to do this is you guys want with maybe whatever title you want + theme
Edit: better image
- 2
-
Made this awhile back, but I don't really PK anymore. (pretty fun account ability to combo 30+ maul 25 dfs 18 venom)
Pretty much all the hard work is done just needs gloves
59 combat
64 hitpoints
5 attack
72 strength
75 defence
noteable skills
99 fishing
72 agility
50 con
-
It's ok I got a jad pet on my goldfarming account
-
When will people learnt hat Thursday is update day. Look on the home page client is OFFLINE.
- 2
-
Not really a bug, but returning 67 as max and 22 as min is clunky.
It should be #getCameraPitch - 128 / 255 * 100
-
-
Please make sure they are under this directory
C:\Users\#USERNMAE_HERE\OSBot\scripts
Also, make sure the scripts you are downloading are currently working or if you're making your own scripts, then make sure they have a script manifest in order for the bot to correctly parse the script.
-
QUIT LURKING AND POST YOU FAGGOTS
-
Rules
Slam your head on the keyboard in Google images and post the first result.
No cheating provide the string result.
Redo
-
When I was in the third grade I thought I was gay
-
If you are going to do something like this, then you should probably have it running on a separate thread s your bot doesn't just sit there doing nothing. Might be more realistic than just straight up logging out when a JMod is around, but it still doesn't look good if all bots in one area just stood still.
-
I don't see why someone cant be a head admin of two different communities. However, he did always seem lazy and couldn't take the pressure of dealing with everything. Cya in 2 weeks when he becomes admin again for the third time.
- 2
-
The spam is real... Good luck..
haha dude I screenshotted the same thing!
Anyways, goodluck man
Mio's Water Sheep
in Money Making
Posted
Nice