Jump to content

[Scripter Noob] Help again :P


Recommended Posts

Posted

ohmy.png

I want to to select the talisman and interact with the ruins

but it only returns the option for tiaras aka "Enter"

 Entity ruins = s.objects.closest("Mysterious ruins");
        if (ruins != null) {
            s.sleep(s.random(3000)+500);
            if (s.getInventory().contains("Air talisman")) {
                if (s.getInventory().getSelectedItemName().equals("Air talisman")) {
                    ruins.interact("Use");
                    s.sleep(s.random(300) + 600);
                } else {
                    s.inventory.getItem("Air talisman").interact("Use"); //if first statement is not true it will select it again (Hoping )
                }
            } else {
                ruins.interact("Enter"); //if you are using a tiara it will just call 'enter' and go inside
                s.sleep(s.random(300) + 1000);
            }
        }
Posted (edited)

 

ohmy.png

I want to to select the talisman and interact with the ruins

but it only returns the option for tiaras aka "Enter"

 Entity ruins = s.objects.closest("Mysterious ruins");
        if (ruins != null) {
            s.sleep(s.random(3000)+500);
            if (s.getInventory().contains("Air talisman")) {
                if (s.getInventory().getSelectedItemName().equals("Air talisman")) {
                    ruins.interact("Use");
                    s.sleep(s.random(300) + 600);
                } else {
                    s.inventory.getItem("Air talisman").interact("Use"); //if first statement is not true it will select it again (Hoping :))
                }
            } else {
                ruins.interact("Enter"); //if you are using a tiara it will just call 'enter' and go inside
                s.sleep(s.random(300) + 1000);
            }
        }

 

Can't help you if you're making a runecrafter ... QwPha8E.png

 

Tip:

Make sure to do inventory.isItemSelected() && s.getInventory().getSelectedItemName().equals("Air talisman")

 

Khaleesi

Edited by Khaleesi
  • Like 1
Posted (edited)


public boolean usePleb(String action, String action2) { // action == the item it is going to select,  action2 == in this case, is the ruins      

     Entity ruins = objects.closest(action2);

     if (inventory.isItemSelected()) { // IF ITEM IS SELECTED
     if (inventory.getSelectedItemName() == action) { // IF THE SELECTED ITEM IS == action
     ruins.interact("Use");
     } else {
     inventory.deselectItem();
     }
     } else {
     inventory.interact("Use", action); // THIS ONE WILL SELECT THE ITEM IF ITEM IS NOT SELECTED
     }
     return true;
     }

to use this just use;

usePleb("Air talisman", "Mysterious Ruins");

Edited by iJodix
  • Like 1
Posted

public boolean usePleb(String action, String action2) { // action == the item it is going to select,  action2 == in this case, is the ruins      

     Entity ruins = objects.closest(action2);

     if (inventory.isItemSelected()) { // IF ITEM IS SELECTED
     if (inventory.getSelectedItemName() == action) { // IF THE SELECTED ITEM IS == action
     ruins.interact("Use");
     } else {
     inventory.deselectItem();
     }
     } else {
     inventory.interact("Use", action); // THIS ONE WILL SELECT THE ITEM IF ITEM IS NOT SELECTED
     }
     return true;
     }

to use this just use;

usePleb("Air talisman", "Mysterious Ruins");

 

 

Here's a nicer version ;)

public boolean usePleb(String itemName, String objectName) {
	if (objectName.isEmpty() || itemName.isEmpty() || !getInventory().contains(itemName)) return false;
	
	Entity localEntity = getObjects().closest(objectName);
	if (localEntity == null || !localEntity.exists()) return false;
	
	if (!localEntity.isVisible()) getCamera().toEntity(localEntity);
	
	if (getInventory().isItemSelected() && !getInventory().getSelectedItemName().equalsIgnoreCase(itemName)) getInventory().deselectItem();
	
	getInventory().interact("Use", itemName);
	localEntity.interact("Use");
	
	return true;
}
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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