-
Posts
240 -
Joined
-
Last visited
-
Feedback
100%
Everything posted by BravoTaco
-
RS2Widget fireBolt = getWidgets().get(201,1,8); RS2Widget spellChoise = getWidgets().get(593,28); if (getSkills().getDynamic(Skill.MAGIC) >= 35) { getTabs().open(Tab.ATTACK); What appears to be happening is that you are setting the variable too soon. You set it before opening the tab, when you to set it after you have verified that the tab is open.
-
Try to use a WebWalkEvent and call useSimplePath() this will try to take a more direct route to the target. It will use more memory but it might help since it won’t try to follow roads. Otherwise you could set a condition for the WebWalkEvent to break when it ventures to far off the path that it has calculated by retrieving it with getPositions() than looping through that finding the closest point that is closest to you and closest to the target point and having a threshold of a overshoot before restarting the event.
-
To get scripter 1 rank you have to apply for it and have a script that is in development or is ready to be put up on the sdn. Go here and read the threads to learn more about the requirements and the process to take to apply. https://osbot.org/forum/forum/181-sdn-requests/ Happy scripting Also feel free to pm me if you have any questions throughout your scripting journey.
-
I would recommend not calling the interact() in the same call as getItem() as it could throw an NPE. Anyways you can try this if the first action is the one you always want to use. Item invItem = getInventory().getItem("ItemName"); if (invItem != null) { String[] actions = invItem.getActions(); if (actions != null) invItem.interact(actions[0]); }
-
Hmmm, you could create a wrapper for when you use the interact() method, so when the interact() returns true than you know it clicked. EX. Might cause problems if the bot had to right click to interact with it though. private Point interact(Entity entity) { Point clickedPoint = null; if (entity.interact()) clickedPoint = getMouse().getPosition(); return clickedPoint; }
-
In the situation of closing the bank, and moving the mouse to the inventory before the bank is closed or as soon as you click close. You could just use widgets to get the close button, interact with the widget and right after interacting with no sleeps just move the mouse over to whatever inventory slot you want. Than wait until the interface is closed before interacting with the inventory item.
-
While (Loops Bad Practice? and Unexpected Result)
BravoTaco replied to Ace99's topic in Scripting Help
While loops have their place, but with bots you really want to only execute one task/function per loop for safety and performance. If you want to use a while loop I would add a counter to set the maximum number of attempts the code can run. That way the while loop can never get stuck. Also I think Mirror Mode is single threaded, so it could cause issues depending on how and when the values used by the API calls are updated. -
Get the position of the guide sign on the screen?
BravoTaco replied to dayong143333333's topic in Scripting Help
https://osbot.org/api/org/osbot/rs07/api/HintArrow.html -
I've noticed that if you call a bank method too soon after the first time of opening the bank it will cause unexpected results. Try to add a sleep after opening the bank.
-
Communication between classes - Why does this not work?
BravoTaco replied to Athylus's topic in Scripting Help
Will need actual code to diagnose why case 1 is not working. As of right now, there is no way to tell what is causing case 1 to fail since the method onLoop() in the CObject class, if statement, does not show the condition. Also if your using a switch system, you should look into Enums to separate the different types of states that your bot will be in. It will make it easier to switch between states since you can set the state based on a series of condition checks. Ex. Declare an Enum with the different states. I'll just use ATTACK, LOOT, BANK states. Than in the main class declare a BotState variable that will hold the current state of the bot. Than create a method that will change the state of the variable in the main class. And add it to the first line of the onLoop() method. Lastly, add the switch statement to the onLoop() method.- 1 reply
-
- 1
-
-
Always use getters when its available. Getters and Setters can be doing alot more under the hood than just returning a variable or just setting it to a different value. Take a look at this thread. In it, the settings variable was not returning the correct value of the run energy, but when he switched it to use the getter it worked.
-
Script unrecognized by osbot when trying to load
BravoTaco replied to FyredUp's topic in Scripting Help
This problem can occur while using the wrong java version when building out the jar. In IntelliJ go to File -> Project Structure -> Project Set the Project SDK to 1.8 Set the Project language level to 8 -
Try this Entity interacting = myPlayer().getInteracting(); if (interacting != null) { if (interacting instanceof RS2Object) { RS2Object object = (RS2Object) interacting; } else if (interacting instanceof NPC) { NPC npc = (NPC) interacting; } }
-
Could be the script, but I haven't seen anyone else complain about lag from it. Try another script and see if the lag continues.
-
What script are you using? Is it self written? Also is the logger printing out any errors?
-
What are you doing with the returned int value in the run()? Also are you sure that 2 is the correct child id of 808 when the quest is complete?
-
Can anyone figure out the problem with this code?
BravoTaco replied to Lol_marcus's topic in Scripting Help
If the code above is the same that you are using and you are trying to access the userChoice variable outside of the onStart() than it will show invalid variable, as you have only created that variable inside of the onStart(). Add the userChoice var to the class and set that value in the onStart(), you will than be able to use that variable. -
You can use getDirectoryData() method to retrieve the path to the data folder, so that if you, or someone else has a different install location it will retrieve the correct path.
-
Can anyone figure out the problem with this code?
BravoTaco replied to Lol_marcus's topic in Scripting Help
By not recognizing your option anymore, do you mean that it is returning a value that was not selected? Or is it that the values in the JOptionPane are not the options you are passing into it? -
With calling settings you are calling the variable itself with getSettings() you are calling a getter that may be doing more than just returning the variable itself. In most cases calling just settings will work but depending on when and where you are calling the settings variable it’s context could possibly not be the current bot context so it is unable to accurately retrieve the information needed while not throwing any errors. To verify this, print what the current value of that call is, to the console.
-
Non-static method cannot be referenced from static context error
BravoTaco replied to Impensus's topic in Scripting Help
As dreameo said singletons are great to use and I recommend that as these classes are being used to execute a task and you would only ever need a single instance of them. As for the error you were getting, this is because of you calling the class name followed by the method. You need to use the variable name followed by the method. IE. Banking banking = new Banking(); banking.method(); Notice the lowercase b. If you use an uppercase than it will reference the class itself. -
Might want to flip that operator (; > - greater than < - less than