Jump to content

[Scripter Noob] Help again :P


Chris

Recommended Posts

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);
            }
        }
Link to comment
Share on other sites

 

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
Link to comment
Share on other sites


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
Link to comment
Share on other sites


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
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...