Jump to content

BravoTaco

Scripter II
  • Posts

    239
  • Joined

  • Last visited

  • Feedback

    100%

About BravoTaco

Profile Information

  • Gender
    Male
  • Location:
    United States

Recent Profile Visitors

3193 profile views

BravoTaco's Achievements

Steel Poster

Steel Poster (4/10)

84

Reputation

  1. Here's a quick example on how you could refactor your code to make it a little more readable and predicatable. First declare an enum class that specifies the current state that your bot should be in. Then create a method to determine the state that the bot should be in. Then create methods for each of those states. Once you have all of that completed, create a variable that will hold the current bot state. Lastly, you just have to setup the main loop of your script. First set that variable using the calculateBotState method. Then implement a switch statement that will call the methods when the bot is in its various states. Hopefully this helps you out in your scripting adventures!
  2. Here's a link to help help explain the difference between static and non-static methods. https://www.geeksforgeeks.org/difference-between-static-and-non-static-method-in-java/
  3. Hello all, I've been out of the scripting scene for a little bit now and was wanting to get back into it, so if anyone wants a particular script created then you can reply here or message me with the details and I'll make it for you. I will most likely attach a link to the source code and compiled .jar file on my GitHub after completion for others to look at and or use. Script complexities will vary based off of how much time I have available to work on it and I may have to turn down some scripts as I don't want to create a free version of something that another scripter has a paid version for.
  4. I am willing to help you out with anything you need, scripting related, all though I won't be able to talk through things on Discord as my current employment requires me to travel around a fair bit. I can however respond to messages, so feel free to reach out whenever you have questions.
  5. If you are not needing an entire GUI, you could use the JOptionPane class, it allows you to bring up a modal input dialog box with just one line of code. String monsterID = JOptionPane.showInputDialog("Please enter the monster ID.");
  6. Sure! No problem! // Basic code to chop a regular tree, with a conditional sleep, when the player is not animating. if (!myPlayer().isAnimating()) { RS2Object tree = getObjects().closest("Tree"); if (tree != null && tree.interact("Chop down")) { // The conditional sleep returns true or false. // True being returned if the condition is met. IE. The player is animating. // False being returned if the condition is not met, and the max sleep time is met. // The sleep time is in milliseconds so 15000 == 15 seconds. if (ConditionalSleep2.sleep(15000, () -> myPlayer().isAnimating())) { log("Player is chopping the tree."); } } }
  7. @mrdukesilver Without having knowledge of the code inside of the other methods, this will be rather hard to debug. Try executing only the worldHop1 method without executing any other code to see if it functions as expected. I also recommend to look into the ConditionalSleep classes. Standard ConditionalSleep class new ConditionalSleep(maxSleepTime, checkInterval) { @Override public boolean condition() throws InterruptedException { return condition; } }.sleep(); Non-Standard ConditionalSleep class - I personally recommend using this one, as it is more straightforward. ConditionalSleep2.sleep(maxSleepTime, () -> condition)
  8. @CheckingItOut You are missing the import for the Message class. I would recommend giving this a look, https://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-or-cannot-resolve-symbol-error-mean It will help explain the error in detail. Adding this to your imports, should fix this though; import org.osbot.rs07.api.ui.Message;
  9. Not at the moment. Don't have the requirements on any account (That I'm willing to bot on) to use.
  10. any luck on any other diary script? im willing to help test

  11. I believe the difference is that completeDialogueU is surrounded in a try-catch, while the other is not. So you can use completeDialogueU without having to catch the exception yourself.
  12. I wrote up a quick example script. Not everything is implemented I left the buyItem() method blank so that you can implement that. It uses an Array of strings for the different items to alch, and a HashMap<String, Integer> that holds the alched count for each item. If you have any questions let me know. Also this code is untested. So it may be broken public class UCAlcher extends Script { private BotState botState; // This is used to keep track of how many of each item that can be alched, has been alched. private final HashMap<String, Integer> alchsMap = new HashMap<>(); // The different items you want to alch. private final String[] itemNames = new String[]{"Rune 2h Sword", "Rune platebody", "Rune platelegs"}; // This value represents how many items will be alched/bought for each item. private int alchLimitForEachItem = 2; private String currentAlchItemName; @Override public void onStart() throws InterruptedException { // Initialize the HashMap with the values from the itemNames array. for (String s : itemNames) { alchsMap.put(s, 0); } } @Override public int onLoop() throws InterruptedException { botState = setBotState(); if (botState != null) { switch (botState) { case ALCH_ITEM: { alchItem(); } case BUY_ITEM: { buyItem(); } } } else { warn("The botState is null."); stop(false); } return random(800, 3600); } private BotState setBotState() { currentAlchItemName = null; // for (Item item : getInventory().getItems()) { if (item != null && alchsMap.containsKey(item.getName()) && alchsMap.get(item.getName()) < alchLimitForEachItem) { currentAlchItemName = item.getName(); return BotState.ALCH_ITEM; } } // If the currentAlchItemName is null here than that means we need to possibly buy a new item to alch // or we need to reset the alch count on each item. if (currentAlchItemName == null) { for (String s : alchsMap.keySet()) { if (alchsMap.get(s) < alchLimitForEachItem) { currentAlchItemName = s; return BotState.BUY_ITEM; } } } // If the currentAlchItemName is still null than that means we have bought and alched all items. // So now we have to reset the alch count on each item and set the currentAlchItemName to the first index in the itemNames array. if (currentAlchItemName == null) { for (String s : alchsMap.keySet()) { alchsMap.replace(s, 0); } currentAlchItemName = itemNames[0]; return BotState.BUY_ITEM; } return null; } private void buyItem() { // Implement the buying of the item here. } private void alchItem() throws InterruptedException { Item alchItem = getInventory().getItem(currentAlchItemName); if (alchItem != null) { if (getMagic().canCast(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY)) { if (getMagic().castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY)) { if (sleepUntil(() -> alchItem.interact("cast"), 5000, 20)) { alchsMap.replace(currentAlchItemName, alchsMap.get(currentAlchItemName) + 1); } else { warn("Unable to alch item."); } } } else { warn("Unable to cast high level alchemy. Stopping script."); stop(false); } } else { warn("The inventory does not contain the required item to alch. Something must have gone wrong when calculating the botState."); } } private boolean sleepUntil(BooleanSupplier condition, int maxTime, int checkInterval) throws InterruptedException { long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < maxTime) { if (condition.getAsBoolean()) { return true; } Thread.sleep(checkInterval); } return false; } private enum BotState { BUY_ITEM, ALCH_ITEM } }
  13. Yeah you are correct, you are essentially setting the pathToBank as a pointer to the pathToAltar so when accessing the pathToBank variable you are actually just accessing the value stored in the pathToAltar. Subsequently if you were to change the pathToAltar value than you would also essentially be changing the value of pathToBank since it is a pointer to that value.
  14. When you added your positions, you may have added them in a reversed order. Try recreating the array/list with the current positions reversed. Or you could do it through code at runtime with a quick Java call. Collections.reverse(pathToAltar); Edit: Just tested the current list you have and it seems to walk correctly from the bank to the air altar, if that is what you are intending. If so than you may have an issue with another part of your script somewhere. Is their more to this script or is it just executing the walking from above?
×
×
  • Create New...