Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question Noob question

Joined
Apr 6, 2016
Messages
34
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?

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!
 
Client Developer
Joined
Oct 12, 2015
Messages
3,781
Change:
Code:
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);
        }
To:
Code:
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);
        }
}
 
Also join the RuneMate Slack #development channel :)

Always people in there willing to help, myself included.
 
Glad you're trying to get involved though, always good to see people trying out something new! Next section of my guide will be incredibly useful to you (as I see you're trying to use LoopingScript).
 
Joined
Apr 6, 2016
Messages
34
Hey thanks @Party for the quick respond.
Will join the dev channel :)

What it does now after changing the code it keeps running in and out the bank
 
Joined
Dec 10, 2014
Messages
3,332
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?

Code:
     if (Inventory.isFull() && !altararea.contains(player)) ;

Thanks!
Pretty sure this line is the issue, maybe you intended to have the following code in that if statement? If so then you use brackets, not a semi-colon.
 
Top