Everything posted by Explv
- Timer help
-
[Need Help] Sorting data from website
Yeah, you can use the JSON Simple library no problem on the SDN. You just have to include the source (which is only a handful of classes). I have updated the original thread: https://osbot.org/forum/topic/102611-ge-data-get-price-etc-by-item-name-no-external-libraries-required/ And also written a new one that uses the JSON Simple library (probably the preferred way) https://osbot.org/forum/topic/126881-ge-data-using-rsbuddy-json-simple-library/
-
GE Data using RSBuddy & JSON Simple library
You will need to include the JSON Simple library in your project (this can also be used on the SDN): https://github.com/fangyidong/json-simple RSExchange.java import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; import java.util.Map; import java.util.Optional; public final class RSExchange { private final JSONObject ITEMS_JSON; public RSExchange() throws Exception { Optional<JSONObject> itemsJSONOpt = getItemsJson(); if (!itemsJSONOpt.isPresent()) { throw new Exception("Failed to get items JSON"); } JSONObject itemsJSONKeyedByID = itemsJSONOpt.get(); JSONObject itemsJSONKeyedByName = new JSONObject(); for (Object itemValue : itemsJSONKeyedByID.values()) { JSONObject itemValueJSON = (JSONObject) itemValue; itemsJSONKeyedByName.put(itemValueJSON.get("name"), itemValueJSON); } ITEMS_JSON = itemsJSONKeyedByName; } private Optional<JSONObject> getItemsJson() { try { URL url = new URL("https://rsbuddy.com/exchange/summary.json"); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); try (InputStreamReader inputStreamReader = new InputStreamReader(con.getInputStream()); BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { JSONParser jsonParser = new JSONParser(); return Optional.of((JSONObject) jsonParser.parse(bufferedReader)); } } catch (Exception e) { e.printStackTrace(); } return Optional.empty(); } public final Map<String, ExchangeItem> getExchangeItems(final String... itemNames) { Map<String, ExchangeItem> exchangeItems = new HashMap<>(); for (final String itemName : itemNames) { getExchangeItem(itemName).ifPresent(exchangeItem -> exchangeItems.put(itemName, exchangeItem)); } return exchangeItems; } public final Optional<ExchangeItem> getExchangeItem(final String itemName) { Object itemObj = ITEMS_JSON.get(itemName); if (itemObj == null) { return Optional.empty(); } JSONObject itemJSON = (JSONObject) itemObj; return Optional.of(new ExchangeItem((String) itemJSON.get("name"), (long) itemJSON.get("id"))); } } ExchangeItem.java import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; public final class ExchangeItem { private final String name; private final long id; private long overallAverage = -1; private long buyAverage = -1; private long sellAverage = -1; private long buyingQuantity; private long sellingQuantity; public ExchangeItem(final String name, final long id) { this.name = name; this.id = id; updateRSBuddyValues(); } public final String getName() { return name; } public final long getId() { return id; } public final long getBuyAverage() { return buyAverage; } public final long getSellAverage() { return sellAverage; } public final long getBuyingQuantity() { return buyingQuantity; } public final long getSellingQuantity() { return sellingQuantity; } public void updateRSBuddyValues() { try { URL url = new URL("http://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + id); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); try (InputStreamReader inputStreamReader = new InputStreamReader(con.getInputStream()); BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { JSONParser jsonParser = new JSONParser(); JSONObject itemJSON = (JSONObject) jsonParser.parse(bufferedReader); overallAverage = (long) itemJSON.get("overall"); sellAverage = (long) itemJSON.get("selling"); buyAverage = (long) itemJSON.get("buying"); buyingQuantity = (long) itemJSON.get("buyingQuantity"); sellingQuantity = (long) itemJSON.get("sellingQuantity"); } } catch (Exception e) { e.printStackTrace(); } } public final String toString() { return String.format("Name: %s, ID: %d, Overall AVG: %d gp, Buying AVG: %d gp, Selling AVG: %d gp, Buying Quantity: %d, Selling Quantity:%d", name, id, overallAverage, buyAverage, sellAverage, buyingQuantity, sellingQuantity); } } Usage: RSExchange rsExchange = new RSExchange(); Optional<ExchangeItem> exchangeItem = rsExchange.getExchangeItem("Yew logs"); exchangeItem.ifPresent(System.out::println); Prints: Name: Yew logs, ID: 1515, Overall AVG: 355 gp, Buying AVG: 354 gp, Selling AVG: 355 gp, Buying Quantity: 67874, Selling Quantity:72956 Or: Map<String, ExchangeItem> exchangeItems = rsExchange.getExchangeItems("Yew logs", "Iron bar"); exchangeItems.values().forEach(System.out::println); Prints: Name: Yew logs, ID: 1515, Overall AVG: 354 gp, Buying AVG: 354 gp, Selling AVG: 354 gp, Buying Quantity: 47056, Selling Quantity:33141 Name: Iron bar, ID: 2351, Overall AVG: 179 gp, Buying AVG: 182 gp, Selling AVG: 177 gp, Buying Quantity: 2765, Selling Quantity:4467
-
[Need Help] Sorting data from website
Right now it just stores the overall price value. I can modify it though to store information. Will update the thread shortly
-
Setting mouse speed
To stop people from changing the mouse speed
- Setting mouse speed
-
[Need Help] Sorting data from website
If you want prices and stuff like that, I have already written a complete solution in the snippets section: https://osbot.org/forum/topic/102611-ge-data-get-price-etc-by-item-name-no-external-libraries-required/ You can modify it to suit your needs accordingly.
-
[Need Help] Sorting data from website
You don't need to sort the data into a more readable form. I just did that to show you what it looks like. Take a look at some JSON tutorials online, if you want to understand how to do it. JSON is very very simple. If you just want the item names, check my above post.
-
[Need Help] Sorting data from website
If this is a just a one off thing though, I wrote a quick python script to do it: import json item_data = {} with open('summary.json', 'r') as summary_file: item_data = json.load(summary_file) item_names = [item_data[item_id]['name'] for item_id in item_data] with open('item_names.txt', 'w') as item_names_file: for item_name in item_names: item_names_file.write(item_name + "\n") And here is the output: https://hastebin.com/dewunamare.sql
-
[Need Help] Sorting data from website
Firstly that file will not include all RuneScape items, only ones tradeable on the Grand Exchange. It is a JSON file, you should use a JSON library to handle the data, such as https://github.com/fangyidong/json-simple or https://github.com/google/gson Here is what the file looks like prettified: { "2": { "id": 2, "members": true, "name": "Cannonball", "sp": 5, "overall_average": 195, "sell_average": 195, "buy_average": 195 }, "6": { "id": 6, "members": true, "name": "Cannon base", "sp": 187500, "overall_average": 179789, "sell_average": 177522, "buy_average": 176043 } } To extract each item you would create a JSONObject of the whole String. Then iterate over each of it's keys, these are the item ids e.g. (2, 6). For each of those keys, get the value (this is the item's information), and then print the value of the "name" key out to a file.
-
Open Source Woodcutting Script
@HeyImJamie Looks nice, good job Just FYI you should be checking if wc levels are >=, rather than >. Right now your script will keep chopping normal trees until level 16, and oaks until level 61. Also you might want to consider using an enum for storing your Tree names & areas. Something like this: enum Tree { NORMAL("Tree", 1, new Area(1, 2, 3, 4)), OAK("Oak", 15, new Area(1, 2, 3, 4)), YEW("Yew", 60, new Area(1, 2, 3, 4)); String name; int levelRequired; Area area; Tree(final String name, final int levelRequired, final Area area) { this.name = name; this.levelRequired = levelRequired; this.area = area; } } You can also avoid having lots of nested if statements, by just inverting them: if (getTreeArea().contains(myPlayer())) { if .. if .. } else { getWalking().webWalk(...); } Becomes: if (!getTreeArea().contains(myPlayer())) { getWalking().webWalk(...); } else if { ... } ...
-
Explv's AIO [13 skill AIO in 1 script]
@FuryShark @Fearsy @sevant @FuryShark Saving / Loading is now fixed on the SDN Note: You will need to recreate any old configs, they will not be able to be loaded.
-
Explv's AIO [13 skill AIO in 1 script]
Pushed a fix for this, will be available when the SDN is updated. Thanks
-
Explv's AIO [13 skill AIO in 1 script]
I have pushed a fix for Saving / Loading, this time it should really fix it Will update again once it is live on the SDN. Thanks
-
What's the story behind your username?
Mashed face on keyboard
-
Trying to make Banking class, Errors
Depends what you mean by state logic, these buzzwords are thrown around so much on here it's hard to tell what people mean by them. And I do think the patterns themselves suck, I won't rant about it again on this thread, but you can see what I said before here:
-
Trying to make Banking class, Errors
Make your class extend MethodProvider: public class Banking extends MethodProvider { // whatever } Then initialize it (once) like so (has to be done in a class that extends MethodProvider, e.g. your main Script class) Banking banking = new Banking(); banking.exchangeContext(getBot()); You will now be able to access all the API methods from inside your Banking class. "Node", "Tasks", "States" all suck Also regarding your initial post, go follow some Java tutorials, especially an OOP tutorial so you can understand why what you wrote is wrong.
-
Open Source Tutorial Island Script
This was the first script I created for OSBot, I have seen many people make / try to make this script, so I figured why not open source mine so that people could learn from it, or use it Source: https://github.com/Explv/Tutorial-Island Jar File: https://github.com/Explv/Tutorial-Island/releases
-
help a noob
Are you serious? Go and actually try to learn Java, follow some Java tutorials and only then attempt to make scripts. You can't just post some fucking completely syntactically and logically incorrect, unformatted code and expect someone to fix it for you.
-
dropAll implementation?
If shift dropping is enabled in the osrs settings, the OSBot dropAll method will use shift dropping afaik.
-
Explv's Walker
That would be a bug in the web walker not my script, you should report it to the OSBot devs. Thanks
-
Mouse Position <-> Ingame Position
You can do something like this to get the Position under mouse: public final Optional<Position> getPositionUnderMouse(final Point mousePosition) { for (int x = 0; x < 104; x++) { for (int y = 0; y < 104; y++) { Position pos = new Position(getMap().getBaseX() + x, getMap().getBaseY() + y, myPosition().getZ()); if (pos.isVisible(getBot()) && pos.getPolygon(getBot()).contains(mousePosition)) { return Optional.of(pos); } } } return Optional.empty(); } Usage: Position position = getPositionUnderMouse(getMouse().getPosition()); You cant really convert a Position to a mouse point, but you can get it's on screen Polygon: Polygon polygon = position.getPolygon(getBot());
-
Will OSBot mobile support multiple tabs?
No bro, you just don't understand. Mobile botting is the future dude, we can have Chinese farms filled with tablets all running 4 bots each. All of the tablets can be linked together with a simple Google Glass interface, so we can have just one employee sitting there monitoring them all easily, see pic:
-
Will OSBot mobile support multiple tabs?
No bro, RuneScape antiban works on mouse movement, if the mouse never moves u can never get banned bro. Think about the opportunities as well, we could add Google glass support, so you can keep an eye on your bots 24/7
- Will OSBot mobile support multiple tabs?