Jump to content

useOn()


dreameo

Recommended Posts

Didn't see an interact method between item and entity. Here's an example (can overload to accept String) :

  • Does not check for item 
  • Does not check for entity
  • returns true on interaction between item and entity

 

Spoiler

private boolean useOn(int itemID, Entity e) throws InterruptedException {

        if(getInventory().getItem(itemID).interact("Use"))
        {
            new ConditionalSleep(10000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getInventory().isItemSelected();
                }
            }.sleep();

            sleep(random.nextInt(500) + 800);

           return e.interact("Use");
        }

        return false;
    }

 

 

Link to comment
Share on other sites

6 minutes ago, dreameo said:

The purpose of sleep is to avoid instantaneous reaction. Otherwise, explain your reasoning. 

The behavior of the method is to interact, not check.

As mentioned, overloading is doable.

If you're aiming for a script on the SDN Alek doesn't support for random numbers/sleeps unless you have a strict math background and have valid reasoning. For private scripts though it's personal preference on your part. :) 

Link to comment
Share on other sites

11 hours ago, dreameo said:

The purpose of sleep is to avoid instantaneous reaction. Otherwise, explain your reasoning. 

The behavior of the method is to interact, not check.

As mentioned, overloading is doable.

 

Alek has multiple posts explaining that sleeps such as the one you have included are not a good idea and are possibly worse than not including them at all,

 

Basically you can plot these sleeps and see a trend which pretty much gives away "bot like behavior" if Jagex wanted to look at it.

 

Secondly yes i understand that the method you wrote is to interact however it also makes sense to include simple checks rather than having to include them multiple times in your code before calling this method, after all that is why we use methods to rerun code without having to rewrite it many times :)

 

I'm simply chucking constructive criticism at you try to help!

Edited by OSRSPsycheDelic
Link to comment
Share on other sites

I understand alek may have posted explaining but, you still haven't given me a valid reason. Saying that its more 'bot like' doesn't prove anything.

 

And yes, I keep behavior strictly to what the method does. Same as the interact method in osbot, you must first check to see if an entity is not null and visible before you interact, it's not the responsibility of the interact method to do that. Simply creating a method to check beforehand is what you're looking for.

 

I never rejected your criticism, i'm asking for clarification. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...