-
Posts
38 -
Joined
-
Last visited
-
Feedback
0%
Posts posted by Canidae
-
-
On 2/1/2021 at 9:05 PM, Nbacon said:
I think this is would be better...
int chain[] ={0,1,2,3,4,5,6,...,28}; int chain[] ={0,4,8,12,16,20,24,1,5,9,13,17,...}; for (int i = 0; i < 28; i++) { Item item =getInventory().getItemInSlot(chain[i]); if (item!=null &&(item.getName().contains("pack"))){ getInventory().interact(chain[i],"Open"); sleep.... } }
This might mess up when trying to pause the script. I would also write it like this:
for (Item item : getInventory().getItems()) { if (item != null && item.getName().equals("Feather pack") && item.interact("Open")) { //sleep } }
-
54 minutes ago, Tom said:
To improve on this, Item#interact returns a boolean if it was successful or not, so you can do
if(inventory.getItemm("Feath pack").interact("Open")) { // Conditional sleep that checks if the number of feather packs in your inventory decreased by 1 }
I would say it depends on the situation. In case of feather packs, I can imagine you don't want to wait a tick everytime you open one since opening them as quick as possible is what you essentially want. You would probably need different code to prevent trying to interact with a non-existent item.
- 3
-
Outside of your question, this is not how you should go on and write this code. What you are trying is to do one method call which results in buying items, without any kind of looping. That's not going to work properly and even if it will, it's unreliable. You can do multiple things. Create an Event class and execute it as an event, let your script loop through it (by using a task system for example) or write a recursive method (not sure if that's a good idea though).
This is an example with an event. When you want to buy items, you will create a new event, pass through the list of items and execute the buying. If you are done buying, you set the event to finished and the script will start looping again. (Not sure if this code works and if it's 100% correct, long time ago for me).
public class Main extends Script { @Override public int onLoop() throws InterruptedException { if (shouldbuyItems()) { BuyItemsEvent event = new BuyItemsEvent(buyItemList); event.exchangeContext(getBot()); execute(event); } return 300; } } public class BuyItemsEvent extends Event { private List<BuyItem> items; public BuyItemsEvent(List<BuyItem> items) { this.items = items; } @Override public int execute() throws InterruptedException { if (!getGrandExchange().isOpen()) { openGE(); } else if (boughtItems()) { setFinished(); } else { buyItems(); } return 300; } public void openGE() { RS2Object geBooth = getObjects().closest("Grand Exchange booth"); NPC exchangeWorker = getNpcs().closest("Grand Exchange Clerk"); int random = new Random().nextInt(2); if (geBooth != null && random == 0) { if (geBooth.interact("Exchange")) { new ConditionalSleep(2500, 3000) { @Override public boolean condition() { return getGrandExchange().isOpen(); } }.sleep(); } } else if (exchangeWorker != null) { if (exchangeWorker.interact("Exchange")) { new ConditionalSleep(2500, 3000) { @Override public boolean condition() { return getGrandExchange().isOpen(); } }.sleep(); } } } }
I also recommend using this class for conditional sleeps:
-
1 hour ago, Chuckle said:
Connectivity is full its ping that's degraded not sure if a repeater will fix the issue as it will still be a long distance from the hub
yeah cable always better than wifi
That's not a repeater, it's a powerline adapter. It will send the connection through the power lines in your house. Your ping won't be affected that much.
-
5 hours ago, Tom said:
I had a $200 debt with OVH, but it was due to a flaw on their end (which they didn't seem to understand) so I acted dumb in a ticket and eventually got it resolved without paying.
This is exactly like dad's advice, which is useless obviously.
-
15 hours ago, ProjectPact said:
Digital Ocean tried to pull the same thing on me. All I did was kindly email them stating what happened, showed I canceled my agreement on PAYPAL, and that I no longer have been using their service. They tried getting $100 out of me. That’s why I stopped using them, and will never use them again.
If you looking for an alternative, take a look at Vultr. It basically offers the same service as DigitalOcean, but cheaper.
-
So to make things clear, you fucked up. Shit happens and you probably forgot about it, or even worse did it intentional. Don't try to make things worse by trying to prevent them from finding you. Contact them through e-mail or give them a call and explain what happened. Don't try to run from it, they will eventually find you anyways and you don't want to battle things like this out in court. (Or however that goes in US). Just at least make sure you don't fuck up like this again and learn from it. A company like that is probably to not going to condone $500 just because you are whatever years old. If you need any help, send me a PM. I have (accidentally) fucked up some stuff in the past as well when I was young.
-
On 6/23/2018 at 6:31 AM, trainux said:
Assuming you say "null", then "eclipse" tells me that it is not an allowed parameter.
An integer can never be null. The best way is to just do getInventory().getAmount().
- 1
-
12 hours ago, aniki432789 said:
something like:
absorpWidget = getWidgets().get(202, 1, 9);
....
currentAbsorp = Integer.parseInt(absorpWidget.getMessage());
Take the time to learn and understand how widgets work and how to use them.
Since widget IDs tend to change, you should use something different instead. For example text color, position or something else.
-
I can make you one for $150 using 2Captcha, source included of course.
-
16 hours ago, Night said:
You should learn some basic Java before attempting to script.
Exactly. You are first using methods on an object and are then nullchecking it for example.
-
11 minutes ago, d0zza said:
Open up any script you've written, then go inside the script manifest but not inside any method, type int foo = 1; and there's your global variable.
I have no clue what you mean.
-
3 minutes ago, d0zza said:
You can have global variables in a script
What do you mean with global variables then? They don't exist in Java and you also said your meaning of global variables aren't (public) static variables. What is it then? The only thing you can do in Java is having public classes with a public static variable in it to make it look like it's some sort of global variable.
-
6 hours ago, d0zza said:
Yes but scripting for osbot does have global variables.
I don't get what you mean?
-
8 hours ago, d0zza said:
I never said it should be static?
Java doesn't really have global variables. So as soon as someone refers to a "global variable" in Java, people will interpret it as a static variable because they share some of their properties.
-
5 hours ago, d0zza said:
Have a global boolean called started that you set to be true inside the action-listener body. Then have an if (started) check in your onLoop.
I recommend you not using this. If the script list is not refreshed, the static fields will keep their values. So as soon as someone stops the script and starts it again without refreshing the list, it will start instantly and probably crash.
-
2 hours ago, R3G3N said:
There are no text widgets and that sleep condition is similar to what I have after I interact with the widget. My problem is that the interaction does not go through and just leaves the option menu hanging. I don't particularly have trouble with widgets in general. It is only this particular one that has a different behavior.
These grid boxes are the widgets. They do not have any texts so I based them off their widget ids.
If you use the Widget debugger, you will find out there are multiple ways on how to detect a widget. You can also use position for example.
-
Looking at your code, I recommend you not playing with trades since you will need some additional checks to make sure you trade the right player etc. etc. Start with something more easy, like a cow killer or a woodcutter.
- 1
-
Contact the scripter who made your script. Best way to do so is by finding his thread about the script and fill in the bug report form.
-
Try to appeal using this link: https://support.runescape.com/hc/en-gb/articles/115002238729-Account-Bans
Your account could be compromised by someone if you weren't using 2nd-factor authentication. Some people clear the bank and bot on the account because they can't change the password.
-
4 hours ago, Alek said:
"Convert strings from files to generate different classes", so essentially ClassReader/Loader? That's not really necessary when you could probably use serialization for whatever you are doing instead - or perhaps it can just be solved with simple file management? We would need more context on what you're trying to do.
Would that also work for scripts on the SDN?
-
3 minutes ago, Blurper said:
I don't quite like custom handlers because they probably don't cover all error cases and requires passing of account data via arguments.
I'll look into the break handler suggestion, thanks.
Still looking for more suggestions!
You can add all error message checks yourself, there's a list which contains all of them with the according number. It's probably the easiest way to do so.
-
You can use a custom login handler. I think @Explv has one in the snippet section. You could also override the break handler, making it break at the time it should be logged out iirc.
- 1
-
Please copy the NPE you got and note which line it came from.
Opening items in inventory
in Scripting Help
Posted · Edited by Canidae
You forgot to check if the interaction actually was succesful, this way you can trigger the sleep without actually having opened the pack.