Welcome!

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

Sign up now!

Bug PowerMiner isn't doing anything

Joined
May 4, 2017
Messages
18
I am a complete java noob trying to learn the runemate API.
Following the tutorial for statescripts from Tutorial - An Introduction to the State-based Script
a simple powerminer is implemented but when I run the code and start the bot on an osrs account, nothing happens. The character just stays idling on its login position. The java code and manifest are:

Code:
package com.legitcurry.bots;
import com.runemate.game.api.script.framework.LoopingScript;
import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
import com.runemate.game.api.hybrid.region.Players;
import com.runemate.game.api.hybrid.entities.GameObject;
import com.runemate.game.api.hybrid.region.GameObjects;
import com.runemate.game.api.hybrid.local.hud.interfaces.SpriteItem;
import com.runemate.game.api.script.Execution;
import com.runemate.game.api.hybrid.local.Camera;
import com.runemate.game.api.hybrid.util.calculations.Random;

/**
* Created by User on 04-Apr-18.
*/

/**
* Skeleton for a State-based Script
* Created by SlashnHax
*/
public class PowerMiner extends LoopingScript {

    private enum State{
        MINE, WAIT, DROP;
    }
    GameObject rocks;
    @Override
    public void onStart(String... args){
        setLoopDelay(150, 600);
    }

    @Override
    public void onLoop() {
        switch(getCurrentState()){
            case MINE:
                rocks = GameObjects.newQuery().names("Iron ore rocks").results().nearest();
                if(rocks != null) {
                    if(!rocks.isVisible()) {
                        Camera.turnTo(rocks);
                    }
                    if(rocks.interact("Mine", rocks.getDefinition().getName())){
                        Execution.delayUntil(()->Players.getLocal().getAnimationId() != -1, 500, 5000);
                    }
                }
                break;
            case DROP:
                int maxAttempts = Random.nextInt(2,5);
                for(int attempts = 0; attempts < maxAttempts && !Inventory.contains("Iron ore"); attempts++){

                    for(SpriteItem i:Inventory.getItems("Iron ore")) {
                        i.interact("Drop");
                        Execution.delay(500, 1000);
                    }
                }
                break;
            case WAIT:

                break;

        }
    }

    @Override
    public void onStop(){
    }

    private State getCurrentState(){
        if(Inventory.isFull()){
            return State.DROP;
        } else if (Players.getLocal().getAnimationId() == -1 || rocks == null || !rocks.isValid()){
            return State.MINE;
        } else{
            return State.WAIT;
        }
    }
}

Code:
<manifest>
    <main-class>com.legitcurry.bots.PowerMiner</main-class>
    <name>Tutorial PowerMiner</name>
    <description>Powermines iron.</description>
    <version>1.0</version>
    <compatibility>
        <game-type>OSRS</game-type>
    </compatibility>
    <categories>
        <category>MINING</category>
    </categories>
    <!--Required to publish on the bot store-->
    <internal-id>TutorialPowerminer</internal-id>
    <!--The rest are optional-->
    <hidden>false</hidden>
    <open-source>true</open-source>
</manifest>

Also the intellij output is the following:
Code:
[Debug] Java Home: E:\Program Files\RuneMate\jre
[Debug] Java Version: 8u121 x86 (Oracle Corporation)
[Debug] Maximum Heap Size: 248MB
[Debug] RuneMate Version: 2.83.3
[Debug] Operating System: Windows 10 x64
Apr 07, 2018 10:05:34 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[Clouse] Downloaded 999 human mouse movements selected for you by Clouse.
00:00:00 INFO    SDK mode is intended for active bot development only. As such, there is a three hour runtime limit while in SDK mode for users who are not Bot Authors. If you are an aspiring Bot Author, please continue on and best of luck! The moment you publish your first bot this limit will be removed. If you are an end user please contact your bot provider and ask them to publish the bot via the Bot Store, so it can be reviewed for safety. For more information please visit <a href="https://www.runemate.com/community/threads/restrict-sdk-runtime-for-end-users.4277/">the discussion thread</a>.
00:00:00 INFO    Logger Initialised - this log file can be found at C:\Users\User\RuneMate\logs\20180407100707_Tutorial PowerMiner.txt
00:00:00 INFO    Logging level can be adjusted in the Preferences tab.
00:00:00 WARN    [Notice: Limited API usage] You're only using a small portion of the api, we recommend you look into some of our EventListeners such as the InventoryListener.
00:00:00 DEBUG    Login Handler has been activated!
00:00:14 DEBUG    Interface Closer - Play Button has been activated!

Any help is appreciated.
 
Joined
May 24, 2016
Messages
1,113
Haha man it's these type of things that make you look like a complete idiot when trying to learn to code, anyway thanks!

All good man! Your IDE should point it out, but it's an easy mistake to make using old tutorials.
 
Top