Jump to content
DeadPk3r

Handling doors then do action

Recommended Posts

Im trying to get my script to walk from location1 to location2 and on the way to location2 there is a door that needs to be opened once opened i want to use a item in my inventory on a object but the problem im having is on the way there when i get to the door script tries to use my inventory item on object even though door is closed, but sometimes rarely will open door then use item on object, posted code below kinda-iffy just really tired atm.

 

if(!UI.cookingArea.contains(myPlayer())) {
    			setStatus("Walking to range/fire.");
    			getWalking().webWalk(UI.cookingArea);
    			if(getDoorHandler().handleNextObstacle(UI.cookingArea)) {
    				new ConditionalSleep(5000) {
						@Override
						public boolean condition() throws InterruptedException {
							return getMap().canReach(range);
						}
					}.sleep();
    			}
    		}
    		if (!getWidgets().isVisible(270, 14)) {
    			setStatus("Using food on range/fire.");
    			getInventory().interact("Use", UI.foodType);
    			if (range.interact("Use")) {
					new ConditionalSleep(2000) {
						@Override
						public boolean condition() throws InterruptedException {
							return getWidgets().isVisible(270, 14);
						}
					}.sleep();
				}
    		}
		 else {
			if (getWidgets().interact(270, 14, "Cook")) {
				setStatus("Cooking food.");
				new ConditionalSleep(100_000) {
					@Override
					public boolean condition() throws InterruptedException {
						return !inventory.contains("Raw") || getDialogues().isPendingContinuation();
					}
				}.sleep();
				if(getDialogues().isPendingContinuation()) {
					getDialogues().clickContinue();
				}
			}
		}

 

Link to comment
Share on other sites

Don't handle doors if you are using web walking. Right now it looks like you're trying to web walk to the area first and then open the door? Since these are static areas and I'm sure you're not traversing the map, save 1-2GB of member and don't use web walking.

If the door is in the same region as the bank (I sure as hell hope it is), then on the script start grab the door object. Create a WalkingEvent and set the break condition to if the door is closed. If the door is closed, WalkingEvent will break, then you can handle the door.


Additionally:
You aren't disposing your GUI, this is lost memory. Dispose of your GUI and keep your variables contained in the script (aka no more GUI.getArea). Also your script will break within a month with all those static ids. 

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

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