Welcome!

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

Sign up now!

First attempt to create a script...

Joined
Jul 24, 2014
Messages
633
Well I finally gave developing a shot and I'm determined to release something functional!
First of all, I tried making a Seren Stone miner based on @SlashnHax 's tutorial power miner.
I haven't changed much of the code but this is what I got so far:
JavaScript:
package com.runemate.skrall.bots.seren

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.script.Execution;
import com.runemate.game.api.script.framework.LoopingScript;
import com.runemate.game.api.hybrid.local.Camera;


/**
* Seren Stone miner by skrall
* based on Slashnhax's Powerminer
*/
public class AFKSerenStones extends LoopingScript {

    private enum State {

        MINE, WAIT
    }


    @Override
    public void onLoop() {
        switch(getCurrentState()){
            case MINE:
                GameObject rocks = GameObjects.newQuery().names("Seren stone").results().nearest();
                if(rocks != null && rocks.getDefinition() != null) {
                    if(!rocks.isVisible()) {
                        Camera.turnTo(rocks);
                    }
                    if(rocks.interact("Mine", rocks.getDefinition().getName())) {
                        Execution.delayUntil(()->Players.getLocal().getAnimationId() != -1, 500, 5000);
                    }
                }
                break;
            case WAIT:
                break;
            }
        }
    }

    @Override
    public void onStop(){
    }

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

Now I got some text that is either appearing red, or has been underlined in red:

JavaScript:
package com.runemate.skrall.bots.seren
Can't resolve symbol 'skrall'. Do I need to add a folder with my username or something?

Code:
Execution.delayUntil(()->Players.getLocal().getAnimationId() != -1, 500, 5000);
',' or ';' expected. The part '()->P is underlined in red. I doublechecked my code and also the code of SNH and I couldn't find anything missing.

JavaScript:
private State getCurrentState(){
Cannot resolve symbol 'State'. I have no idea what I'm doing wrong here to be honest lol.

Feedback is very much appreciated! Once I get this working I'll try to finetune the delays some more and maybe I'll add a paint too! :)
 
Joined
Jul 24, 2014
Messages
633
I found this printed out copy of C++: How to Program by Deitel & Deitel in my leftovers from school. Does this give me a decent basis for Java?
 
Joined
Dec 10, 2014
Messages
3,301
I found this printed out copy of C++: How to Program by Deitel & Deitel in my leftovers from school. Does this give me a decent basis for Java?
I'd say the tutorials on the Oracle website would give you a decent basis for Java
 
Joined
Nov 26, 2014
Messages
616
I found this printed out copy of C++: How to Program by Deitel & Deitel in my leftovers from school. Does this give me a decent basis for Java?
If you want to learn java, read a book on java and do some trial and error.

You can read all the books in the world and take every programming class, and you won't learn anything unless you write the code and attempt to problem solve yourself.
 
Top