Jump to content

Interact doesn't work as expected?


jakealaka9

Recommended Posts

Hello, I'm still very new to OSBot coding, and I don't understand why my doing (inventory.interact("Use", "Tinderbox", "Logs")) only selects either logs or tinderbox, whichever comes first. Could someone explain?

 

EDIT: Okay so I found a workaround, although I would still like original question answered. Also, now I'm having problems with what it returns. For some reason this doesn't seem to return false, so my player wont move. I decided I would just paste this snippet. I realize it's not made the best way it can be right now, so if you guys have any suggestions, feel free to add them.

while(script.inventory.contains("Logs")) 
        {
            if(!script.myPlayer().isAnimating())
            {
                script.inventory.interact("Use", "Tinderbox");
                if(!script.inventory.interact("Use", "Logs"))
                {
                    if(!script.walking.walk(new Position(script.myPlayer().getX()+1, script.myPlayer().getY(),
                            script.myPlayer().getZ())))
                    {
                        if(!script.walking.walk(new Position(script.myPlayer().getX()-1, script.myPlayer().getY(),
                                script.myPlayer().getZ())))
                        {
                            if(!script.walking.walk(new Position(script.myPlayer().getX(), 
                                    script.myPlayer().getY()+1, script.myPlayer().getZ())))
                            {
                                script.walking.walk(new Position(script.myPlayer().getX(), 
                                        script.myPlayer().getY()-1, script.myPlayer().getZ()));
                            }
                        }
                    }
                }
            }
            MethodProvider.sleep(MethodProvider.random(300, 400));

Edited by jakealaka9
Link to comment
Share on other sites

There's no method for interact (item1, action, item2).
https://osbot.org/api/org/osbot/rs07/api/util/ItemContainer.html#interact-int-java.lang.String...-

You should look into conditional sleeps. Use them between selecting the item and interacting, then sleeping until the action is done or no action is done for a set amount of time. I'm gonna go on a limb here and imagine you're working on a firemaking script. You should check for pre-existing fires in your current spot as well as the spot behind you, before even attempting to interact. Also, you'll need to make sure that you can actually walk to the tile.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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