

NoxMerc
Members-
Posts
74 -
Joined
-
Last visited
-
Feedback
0%
Everything posted by NoxMerc
-
All good! Here is what I'm using to test. public class RSBuddyExchangeOracleTester { private static final String[] NAMES_TO_TEST = new String[] { "Clay", "Adamant pickaxe", "Rune axe", "Mithril platebody" }; private static final int[] IDS_TO_TEST = new int[] { 434, 532 }; // clay, big bones public static void main(String[] args) throws IOException { System.out.println("Testing RSBuddy Exchange Oracle"); long start = System.currentTimeMillis(); RSBuddyExchangeOracle.retrievePriceGuide(); System.out.println("Took " + (System.currentTimeMillis() - start) + "ms to load prices"); for(int i : IDS_TO_TEST) { System.out.println("Testing " + i); RSBuddyExchangePrice price = RSBuddyExchangeOracle.getItemByID(i); System.out.println(price); } for(String s: NAMES_TO_TEST) { System.out.println("Testing " + s); RSBuddyExchangePrice price = RSBuddyExchangeOracle.getItemByName(s); System.out.println(price); } System.out.println("Total time taken: " + (System.currentTimeMillis() - start) + "ms"); } } With WeakHashMap, the two ID tests consistently return null. With HashMap, they work out okay. Am I misusing the Oracle in some way?
-
I...I did. That's what the second picture proves.
-
Really cool. This is exactly one step below what I'm making, where the script itself is responsible for determining the next task and executing it. I'll probably use this as a reference for implementing some of the tasks I have.
-
It's fine for my use case and simplifies my code a bit. I purposefully did it so that I wasn't constantly executing through the script. I see where you are coming from though.
-
Thought I'd add a comment here instead of a new thread. Made a smol addition to the Sleep class that saves some lines of code down the road. public static <k> k untilNotNull(final Supplier<k> locator, final int timeout, final int interval) { Sleep.until(() -> locator.get() != null, timeout, interval); return locator.get(); } Using this, you can essentially wait for an item to be not-null, and it'll return it. Like so: RS2Object coal = Sleep.untilNotNull(() -> ctx.getObjects().closest(ent -> MiningEntity.COAL.hasOre(ent)), 15_000, 750); if (coal == null) //ABORT I could save an additional call to the locator by wrapping the <k> in a mutable final object, but meh.
-
Use the Widgets debugging tool to find the appropriate widget to indicate a trade has been modified. If I recall right the modification is shown by a red and text letting you know to double-check. You can scan for the existence of the text, or the sprite of the
-
Which just validates what I'm saying even further. Rather then continually keeping up with the changes the client makes each revision to ensure the integrity of the packets (if Jagex does any of that), you just manipulate the client's mouse/kb input, which is at a higher level than its packets.
-
And you don't know why you think it doesn't work, which is a problem. It probably worked as intended, you're just using it incorrectly. You have an object, not a numeric (int/long) representation of a price. This is why I said you have a fundamental misunderstanding. That GE Price API gave you back a price object, not a number.
-
You have some fundamental lack of understanding of Java (and/or programming) in general that's going to have you coming back here every other day for help on topics you should already know. The RSBuddyExchangePrice is an object, not a String.
-
Why is this necessary on the packet level? Why mess with packets at all? You can achieve the same thing by recording your screen for 10 minutes legit and then recording the bot for 10 minutes and keep tinkering with it until you're satisfied.
-
We're not mind readers here. What's not working and what have you tried? Post the complete source of your code.
-
I needed an easy way to buy and sell items, not giving a shit about the cost of the items. I also needed to operate with only item names, because handling IDs for the script I'm writing is out of the question. QuickExchange lets you buy and sell GE items in one line of code, using the +-5% modifiers to try to ensure you succeed. QuickExchange extends MethodProvider, so you'll have to add a getter for it somewhere. I also use the conditional sleeps and WidgetActionFilters courtesy of Explv, and a small Wrapper class because Java's lambda enclosure rules suck. ctx.getQuickExchange().open(); ctx.getQuickExchange().quickSell("Coal", 2); ctx.getQuickExchange().quickBuy("Amulet of power", 1, false); Preview QuickExchange.java Sleep.java WidgetActionFilter.java Wrapper.java QuickExchange.java
-
-
Two things. The biggest sin you're committing is that you're acquiring an RS2Object, storing it in a variable, and then waiting for one of its properties (modifiedColors) to magically change. Do you see the issue here? The other is that clay respawns relatively quickly. You're checking once every second if the rock (with the magically-updating fields??) doesn't have ore, but what if clay always has ore between one-second intervals?
-
Preventing events from triggering at the same time.
NoxMerc replied to Zummy's topic in Scripting Help
You can't have two events trigger simultaneously if they're both blocking (synchronous) events, and there's really no reason to make a LoginHandler asynchronous, so you should be good to go. -
Trying to paste a link to Github and get it to work, couldn't, and now I'm banned from the chat for an indeterminate amount of time
-
-
Yo. For the past few weeks I've been in the discord I've been running into scenarios where messages get deleted randomly based on arbitrary text. This isn't an isolated incident -- plenty of others have had their messages deleted too. Example: https://i.imgur.com/2IfswBS.gifv This is extremely frustrating when you type out messages with code inside them, only to have all it all immediately deleted. The workaround is to preemptively copy your message, send ".", and edit your "." with your real message. That's insufferable. Thanks. https://i.imgur.com/YCocj7Q.png https://i.imgur.com/YvQQaUN.png
-
Why not just make an enum for the areas and map the available NPCs to them? You don't need to have a runtime calculation to determine what NPCs are in your area when you have prior knowledge. public enum NpcArea { CHICKENS("Chicken", new Area(x1, y1, x2, y2)), BARBARIANS("Barbarian", new Area(x1, y1, x2, y2)); private final String npcName; private final Area area; NpcArea(String name, Area area) { this.npcName = name; this.area = area; } public static NpcArea fromMyLocation(MethodProvider api) { return Arrays.stream(NpcArea.values()).filter(f -> f.area.contains(api.myPosition())).findFirst().orElse(null); } } And then later on... NpcArea myArea = NpcArea.fromMyLocation(this); // Store this for later use if (myArea == null) { // Walk to area } else { NPC npcToAttack = npcs.closest(myArea.npcName); }
-
// Create a list of items we want to find List<String> itemsToFind = Arrays.asList("Tinderbox", "Falador teleport", "..."); // .stream -> Create a stream from our List. Streams a way of processing lists of data in a functional manner // .allMatch -> Returns true if and only if all items of the stream pass this test // getInventory::contains -> Method Reference to our local function getInventory().contains(). // The method reference implicitly passes in our lambda expression parmaeter, which is a string. // To write this our long-form, you would do ".allMatch(itemName -> getInventory().contains(itemName))" boolean contains = itemsToFind.stream().allMatch(getInventory()::contains); Commented it a bit for you as well. Streams, Lambdas, and Method References offer more concise ways to execute code. Bear in mind that it's not faster to use Streams in most cases, but they often offer more clarity.
-
There's two concepts that java8 introduces, Streams and Lambdas. People here have written tutorials, and there are infinitely more tutorials on the internet. The double-colon is called a Method Reference. https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html
-
List<String> itemsToFind = Arrays.asList("Tinderbox", "Falador teleport", "..."); List<String> inventoryItems = Arrays.stream(ctx.getInventory().getItems()).map(Item::getName).collect(Collectors.toList()); boolean containsAll = inventoryItems.containsAll(itemsToFind); Might be more efficient to get the items once rather than constantly querying. Otherwise.. List<String> itemsToFind = Arrays.asList("Tinderbox", "Falador teleport", "..."); boolean contains = itemsToFind.stream().allMatch(getInventory()::contains);