- Thread Author
- #1
Hey,
So i just started learning to understand the code and make my own script.
What does it do now? Withdraws the essence from the bank and then runs to the path. After 2 tiles it runs back and is doing the banking thing again. What am i doing wrong?
Thanks!
So i just started learning to understand the code and make my own script.
What does it do now? Withdraws the essence from the bank and then runs to the path. After 2 tiles it runs back and is doing the banking thing again. What am i doing wrong?
Code:
package com.jst94.aircrafter;
import com.runemate.game.api.hybrid.entities.GameObject;
import com.runemate.game.api.hybrid.entities.Player;
import com.runemate.game.api.hybrid.local.hud.interfaces.Bank;
import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
import com.runemate.game.api.hybrid.location.Area;
import com.runemate.game.api.hybrid.location.Coordinate;
import com.runemate.game.api.hybrid.location.navigation.Traversal;
import com.runemate.game.api.hybrid.location.navigation.basic.BresenhamPath;
import com.runemate.game.api.hybrid.location.navigation.web.WebPath;
import com.runemate.game.api.hybrid.region.GameObjects;
import com.runemate.game.api.hybrid.region.Players;
import com.runemate.game.api.script.Execution;
import com.runemate.game.api.script.framework.LoopingScript;
import com.runemate.game.api.script.framework.listeners.InventoryListener;
/**
* Created by Admin on 5/31/2016.
*/
public class JstAirCrafter extends LoopingScript implements InventoryListener {
private final static Player player = Players.getLocal();
private final static Area bankarea = new Area.Rectangular(new Coordinate(3012, 3358, 0), new Coordinate(3014, 3355, 0));
private final static Area altararea = new Area.Rectangular(new Coordinate(2988, 3292, 0), new Coordinate(2983, 3290, 0));
@Override
public void onStart(String... args) {
setLoopDelay(400, 500);
getEventDispatcher().addListener(this);
}
public void onLoop() {
setLoopDelay(400, 500);
if (Inventory.isEmpty() && bankarea.contains(player)) ; //Withdraws essence from the bank + check for bank
if (!Bank.isOpen()) {
Bank.open();
Execution.delay(200, 300);
} else {
Bank.withdraw(1436, 28);
Execution.delay(200, 300);
}
if (Inventory.isFull() && !altararea.contains(player)) ;
final WebPath altarpath = Traversal.getDefaultWeb().getPathBuilder().buildTo(altararea.getCenter()); // builds a path to the altar
final BresenhamPath failaltarpath = BresenhamPath.buildTo(altararea.getCenter()); //Builds a fail path to the altararea
if (altarpath != null) {
altarpath.step();
} else if (failaltarpath != null) {
failaltarpath.step();
}
GameObject entrance = GameObjects.getLoaded(1).nearestTo(player); //Checks if the altar is loaded on the game
if (altararea.contains(player)) ;
{
if (entrance != null && entrance.isValid()) {
entrance.interact("Enter Mysterious ruins");
}
}
}
}
Thanks!