Jump to content

Explv

Scripter II
  • Posts

    2314
  • Joined

  • Last visited

  • Days Won

    6
  • Feedback

    100%

Everything posted by Explv

  1. I'm pretty sure the built in solver does the same thing as your code, have you tested this with the same random events that the built in solver doesn't work for? Did you file a bug report detailing the case where it didn't work so that the devs can fix it?
  2. Have you updated to the latest version? 5.1 I added a fix for this
  3. Why would you sort the Areas to determine if you are in the closest bank? Just loop over the Area[]... if you are in one of the Areas, guess what? You are in the closest bank. To walk to the closest bank you can just call getWalking().webWalk(bankAreas)
  4. All you need to do is check if any of the Areas in the Area[] contain your Position. I'll give you a hint, you might want to use a for loop: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html
  5. Consider reading this tutorial on Arrays: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
  6. This is how you integrate JavaFX into a Swing application: https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/swing-fx-interoperability.htm It's probably safer to just use Swing though
  7. I have updated the account switching to use the built in OSBot method, so it will work without using the default account or disabling randoms
  8. I will fix it tonight and notify you when it is uploaded.
  9. I'm a douche for not writing your script for you? I don't see how recommending that you spend some more time learning Java to help yourself makes me a douche either.
  10. String class: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html A tutorial on variables: https://www.tutorialspoint.com/java/java_variable_types.htm
  11. Yes and I have helped you, this is the scripting help section, not the teaching basics of Java section You get the parameters String using: String parameters = getParameters(); Parse the information you need from the String, store the results. Then when you want to withdraw from the bank you use getBank().withdraw(String itemName, int amount); Using your stored information. I am not going to write down every line of code to do that, because you should be able to do it if you have basic knowledge of Java. Which is why I am recommending, that if you DONT know how to do that, then you should learn some more Java then come back to Scripting.
  12. I have shown you how to get the parameters String, parse the information you need from that String using whatever format you want. If you don't know what to do after that, I would recommend that you spend some more time learning Java, because this isn't really a scripting help question, it's just basic programming.
  13. You can withdraw items from the bank using: getBank().withdraw(String itemName, int amount); Consider reading the API documentation: http://osbot.org/api/org/osbot/rs07/api/Bank.html#withdraw-java.lang.String-int-
  14. You get the script parameters string using the getParameters() method in the Script class String parameters = getParameters();
  15. That would require the mule to be always logged on, which isn't really what op was trying to achieve
  16. You could try doing something like this: @ Override public void pause() { if (getBot().getRandomExecutor().getTimeUntilBreak() == 0) { pickUpCannon(); } }
  17. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { Example example = new Example(); example.getItemsJson().ifPresent(json -> { example.getItemID(json, "Greenman's ale").ifPresent(System.out::println); example.getItemID(json, "Cannonball").ifPresent(System.out::println); example.getItemID(json, "Raw trout").ifPresent(System.out::println); example.getItemID(json, "Rune scimitar").ifPresent(System.out::println); example.getItemID(json, "Lobster").ifPresent(System.out::println); }); } private Optional<Integer> getItemID(final String json, final String itemName) { return getItemFromJson(json, itemName).flatMap(this::getItemIDFromItemJson); } private Optional<String> getItemFromJson(final String json, final String itemName) { Matcher matcher = Pattern.compile("(\\{[^}]*\"name\"\\s*:\\s*\"" + Pattern.quote(itemName) + "\"[^}]*})").matcher(json); return matcher.find() ? Optional.of(matcher.group(1)) : Optional.empty(); } private Optional<Integer> getItemIDFromItemJson(final String json) { Matcher matcher = Pattern.compile("\"id\"\\s*:\\s*(\\d*)").matcher(json); return matcher.find() ? Optional.of(Integer.parseInt(matcher.group(1))) : Optional.empty(); } private Optional<String> 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 in = new InputStreamReader(con.getInputStream()); BufferedReader br = new BufferedReader(in)) { String json = br.readLine(); json = json.replaceAll("\\\\u0027", "'"); json = json.replaceAll("\\\\u0026", "&"); return Optional.of(json); } } catch (IOException e) { e.printStackTrace(); } return Optional.empty(); } } Output: 8522 2 335 1333 379
  18. I noticed there was a slight error in one of the regex patterns, it may have been causing issues for you. I have fixed it in the original post.
  19. Do you mean smelting? Because I just tested smelting gold bars and it works fine. I just tested making gold amulet (u)s and it doesn't stop after making 8 for me. Do you mean stringing amulets?
  20. I have pushed fixes for both of these issues, they will be available when the SDN is next updated, thanks.
  21. I have pushed a fix for selecting the option at the start of Tutorial Island. It will be available when the SDN is updated, thanks.
  22. I think that the space complexity is O(n) because the method returns a generator, essentially meaning that it generates each value on request. The only thing stored is the input which is O(n)Regarding time complexity, I would assume that it is O(n!) to generate all of the permutations.
×
×
  • Create New...